I am using TransferManager. uploadDirectory() to upload a folder with htmls, images and videos files to s3. But can't access the content after upload successful.
I notice that the below uploadDirectory method have the argument about permission but have no idea how to use it.
Is there any example about this? Thanks a lot.
public MultipleFileUpload uploadDirectory(String bucketName,
String virtualDirectoryKeyPrefix,
File directory,
boolean includeSubdirectories,
ObjectMetadataProvider metadataProvider,
ObjectTaggingProvider taggingProvider,
ObjectCannedAclProvider cannedAclProvider)
Hi @megolee, take a look at the Access Control List (ACL) Overview.
The ObjectCannedAclProvider will receive a callback via the provideObjectCannedAcl method, allowing you to customize the canned ACL for each object being uploaded.
Here's an example on how to use the ObjectCannedAclProvider interface:
ObjectCannedAclProvider cannedAclProvider = new ObjectCannedAclProvider() {
public CannedAccessControlList provideObjectCannedAcl(File file) {
// If this file is a JPEG, it will be granted private canned ACL;
// otherwise, the file will receive the public-read canned ACL
if (isJPEG(file)) {
return CannedAccessControlList.Private;
}
return CannedAccessControlList.PublicRead;
}
}
MultipleFileUpload multiUpload = transferManager.uploadDirectory(bucketName, keyPrefix,
directory, includeSubdirectories, null, null, cannedAclProvider);
Let us know if that helps.
@debora-ito Yes, it helps me well. Thank you so much.
Most helpful comment
Hi @megolee, take a look at the Access Control List (ACL) Overview.
The
ObjectCannedAclProviderwill receive a callback via theprovideObjectCannedAclmethod, allowing you to customize the canned ACL for each object being uploaded.Here's an example on how to use the
ObjectCannedAclProviderinterface:Let us know if that helps.