use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project goobi-workflow by intranda.
the class S3FileUtils method uploadFile.
@Override
public void uploadFile(InputStream in, Path dest, Long contentLength) throws IOException {
if (getPathStorageType(dest) == StorageType.LOCAL) {
nio.uploadFile(in, dest);
return;
}
ObjectMetadata om = new ObjectMetadata();
om.setContentType(Files.probeContentType(dest));
om.setContentLength(contentLength);
// use regular put method if file is smaller than 4gb
try {
// use multipart upload for larger files larger than 1GB
Upload upload = transferManager.upload(getBucket(), path2Key(dest), in, om);
upload.waitForCompletion();
} catch (AmazonClientException | InterruptedException e) {
throw new IOException(e);
}
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project micronaut-aws-sdk by agorapulse.
the class SimpleStorageServiceTest method buildMetadata.
private static ObjectMetadata buildMetadata() {
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setContentLength(SAMPLE_CONTENT.length());
objectMetadata.setContentType("text/plain");
objectMetadata.setContentDisposition("bar.baz");
return objectMetadata;
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project jornada-back by ValdirCezar.
the class S3ServiceImpl method uploadFile.
@Override
public URI uploadFile(String fileName, InputStream inputStream, String contentType, Long classId) {
try {
var metadata = new ObjectMetadata();
metadata.setContentType(contentType);
s3Client.putObject(bucketName + "/classes/classId-" + classId, fileName, inputStream, metadata);
return s3Client.getUrl(bucketName, fileName).toURI();
} catch (URISyntaxException e) {
throw new FileException("Erro ao converter URL para URI");
}
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project entrada by SIDN.
the class S3FileManagerImpl method uploadFile.
private boolean uploadFile(File src, S3Details dstDetails, boolean archive) {
PutObjectRequest request = new PutObjectRequest(dstDetails.getBucket(), FileUtil.appendPath(dstDetails.getKey(), src.getName()), src);
ObjectMetadata meta = new ObjectMetadata();
if (archive) {
meta.setHeader(Headers.STORAGE_CLASS, StorageClass.fromValue(StringUtils.upperCase(archiveStorageClass)));
}
if (encrypt) {
meta.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
}
request.setMetadata(meta);
try {
amazonS3.putObject(request);
return true;
} catch (Exception e) {
log.error("Error while uploading file: {}", src, e);
}
return false;
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project TDP by hyeyoungs.
the class FileService method uploadImage.
public String uploadImage(MultipartFile file) throws IOException {
String fileName = createFileName(file.getOriginalFilename());
String url;
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setContentLength(file.getSize());
objectMetadata.setContentType(file.getContentType());
try (InputStream inputStream = file.getInputStream()) {
uploadOnS3(fileName, inputStream, objectMetadata);
url = defaultUri + fileName;
} catch (IOException ioe) {
url = null;
}
return url;
}
Aggregations