use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project XHuiCloud by sindaZeng.
the class OssService method upload.
/**
* @param bucketName 存储桶
* @param fileName 文件名
* @param stream 文件流
* @param size 大小
* @param contextType 类型
* @return
* @throws Exception
*/
public PutObjectResult upload(String bucketName, String fileName, InputStream stream, long size, String contextType) throws Exception {
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setContentLength(size);
objectMetadata.setContentType(contextType);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(IOUtils.toByteArray(stream));
return amazonS3.putObject(bucketName, fileName, byteArrayInputStream, objectMetadata);
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project kafka-large-message-serde by bakdata.
the class AmazonS3Client method putObject.
@Override
public String putObject(final byte[] bytes, final String bucket, final String key) {
try (final InputStream content = new ByteArrayInputStream(bytes)) {
final ObjectMetadata metadata = createMetadata(bytes);
this.s3.putObject(bucket, key, content, metadata);
return asURI(bucket, key);
} catch (final IOException e) {
throw new SerializationException("Error backing message on S3", e);
}
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project kafka-large-message-serde by bakdata.
the class AmazonS3Client method createMetadata.
private static ObjectMetadata createMetadata(final byte[] bytes) {
final ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(bytes.length);
return metadata;
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project trino by trinodb.
the class TrinoS3FileSystem method customizePutObjectRequest.
private void customizePutObjectRequest(PutObjectRequest request) {
if (request.getMetadata() == null) {
request.setMetadata(new ObjectMetadata());
}
if (sseEnabled) {
switch(sseType) {
case KMS:
request.setSSEAwsKeyManagementParams(getSseKeyManagementParams());
break;
case S3:
request.getMetadata().setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
break;
}
}
request.setCannedAcl(s3AclType.getCannedACL());
request.setRequesterPays(requesterPaysEnabled);
request.setStorageClass(s3StorageClass.getS3StorageClass());
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project trino by trinodb.
the class TestTrinoS3FileSystem method testEmptyDirectory.
@Test
public void testEmptyDirectory() throws Exception {
try (TrinoS3FileSystem fs = new TrinoS3FileSystem()) {
MockAmazonS3 s3 = new MockAmazonS3() {
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest) {
if (getObjectMetadataRequest.getKey().equals("empty-dir/")) {
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setContentType(S3_DIRECTORY_OBJECT_CONTENT_TYPE);
return objectMetadata;
}
return super.getObjectMetadata(getObjectMetadataRequest);
}
};
fs.initialize(new URI("s3n://test-bucket/"), new Configuration(false));
fs.setS3Client(s3);
FileStatus fileStatus = fs.getFileStatus(new Path("s3n://test-bucket/empty-dir/"));
assertTrue(fileStatus.isDirectory());
fileStatus = fs.getFileStatus(new Path("s3n://test-bucket/empty-dir"));
assertTrue(fileStatus.isDirectory());
}
}
Aggregations