use of com.amazonaws.services.s3.internal.Mimetypes in project studio by craftercms.
the class AwsS3ServiceImpl method listItems.
/**
* {@inheritDoc}
*/
@Override
@HasPermission(type = DefaultPermission.class, action = "s3 read")
public List<S3Item> listItems(@ValidateStringParam(name = "siteId") @ProtectedResourceId("siteId") String siteId, @ValidateStringParam(name = "profileId") String profileId, @ValidateStringParam(name = "path") String path, @ValidateStringParam(name = "type") String type) throws AwsException {
S3Profile profile = getProfile(siteId, profileId);
AmazonS3 client = getS3Client(profile);
List<S3Item> items = new LinkedList<>();
Mimetypes mimetypes = Mimetypes.getInstance();
MimeType filerType = StringUtils.isEmpty(type) || StringUtils.equals(type, ITEM_FILTER) ? MimeTypeUtils.ALL : new MimeType(type);
String prefix = StringUtils.isEmpty(path) ? path : normalizePrefix(path);
ListObjectsV2Request request = new ListObjectsV2Request().withBucketName(profile.getBucketName()).withPrefix(prefix).withDelimiter(delimiter);
ListObjectsV2Result result;
do {
result = client.listObjectsV2(request);
result.getCommonPrefixes().stream().map(p -> new S3Item(StringUtils.removeEnd(StringUtils.removeStart(p, prefix), delimiter), p, true)).forEach(items::add);
result.getObjectSummaries().stream().filter(o -> !StringUtils.equals(o.getKey(), prefix) && MimeType.valueOf(mimetypes.getMimetype(o.getKey())).isCompatibleWith(filerType)).map(o -> new S3Item(StringUtils.removeStart(o.getKey(), prefix), createUrl(profileId, o.getKey()), false)).forEach(items::add);
request.setContinuationToken(result.getNextContinuationToken());
} while (result.isTruncated());
return items;
}
use of com.amazonaws.services.s3.internal.Mimetypes in project aws-sdk-android by aws-amplify.
the class EncryptionUtils method updateMetadataWithEncryptionInstruction.
/**
* Update the request's ObjectMetadata with the necessary information for
* decrypting the object
*
* @param request Non-null PUT request encrypted using the given instruction
* @param instruction Non-null instruction used to encrypt the data in this
* PUT request.
*/
public static void updateMetadataWithEncryptionInstruction(PutObjectRequest request, EncryptionInstruction instruction) {
byte[] keyBytesToStoreInMetadata = instruction.getEncryptedSymmetricKey();
Cipher symmetricCipher = instruction.getSymmetricCipher();
Map<String, String> materialsDescription = instruction.getMaterialsDescription();
ObjectMetadata metadata = request.getMetadata();
if (metadata == null)
metadata = new ObjectMetadata();
if (request.getFile() != null) {
Mimetypes mimetypes = Mimetypes.getInstance();
metadata.setContentType(mimetypes.getMimetype(request.getFile()));
}
updateMetadata(metadata, keyBytesToStoreInMetadata, symmetricCipher, materialsDescription);
request.setMetadata(metadata);
}
use of com.amazonaws.services.s3.internal.Mimetypes in project aws-sdk-android by aws-amplify.
the class S3CryptoModuleBase method updateMetadataWithContentCryptoMaterial.
protected final ObjectMetadata updateMetadataWithContentCryptoMaterial(ObjectMetadata metadata, File file, ContentCryptoMaterial instruction) {
if (metadata == null) {
metadata = new ObjectMetadata();
}
if (file != null) {
final Mimetypes mimetypes = Mimetypes.getInstance();
metadata.setContentType(mimetypes.getMimetype(file));
}
return instruction.toObjectMetadata(metadata, cryptoConfig.getCryptoMode());
}
use of com.amazonaws.services.s3.internal.Mimetypes in project tbbtalentv2 by talentbeyondboundaries.
the class S3ResourceHelper method addObjectMetadata.
public void addObjectMetadata(S3ObjectSummary objectSummary) {
ObjectMetadata metadata = new ObjectMetadata();
Mimetypes mimetypes = Mimetypes.getInstance();
metadata.setContentType(mimetypes.getMimetype(objectSummary.getKey()));
final CopyObjectRequest request = new CopyObjectRequest(objectSummary.getBucketName(), objectSummary.getKey(), objectSummary.getBucketName(), objectSummary.getKey()).withSourceBucketName(objectSummary.getBucketName()).withSourceKey(objectSummary.getKey()).withNewObjectMetadata(metadata);
amazonS3.copyObject(request);
}
Aggregations