英文:
Retrieve file path during S3TransferManager.uploadDirectory
问题
我想上传一个目录,使用S3TransferManager v2的新版本(https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/transfer-manager.html)。
除了内容类型之外,一切都正常:我需要根据文件名设置文件的内容类型。因此,我想使用
UploadDirectoryRequest.Builder uploadFileRequestTransformer(Consumer<UploadFileRequest.Builder> uploadFileRequestTransformer)
但是我不知道如何获取要上传的文件的文件路径。
你有任何想法吗?
英文:
I want to upload a directory with the new version of S3TransferManager v2 (https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/transfer-manager.html).
Everything works well except for the content type: I need to set the file content type according to the file name. For this reason, I thought to use the
UploadDirectoryRequest.Builder uploadFileRequestTransformer(Consumer<UploadFileRequest.Builder> uploadFileRequestTransformer)
But I don't know how can I retrieve the file path of the file that is going to be uploaded
Do you have any idea?
答案1
得分: 0
我找到了解决方案。
在uploadFileRequestTransformer
中,我可以通过以下方式获取文件:
UploadFileRequest uploadFileRequest = uploadFileRequestBuilder.build();
File file = uploadFileRequest.source().toFile();
英文:
I found the solution.
Inside the uploadFileRequestTransformer
I can retrieve the file in this way
UploadFileRequest uploadFileRequest = uploadFileRequestBuilder.build();
File file = uploadFileRequest.source().toFile();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论