在S3TransferManager.uploadDirectory期间检索文件路径。

huangapple go评论85阅读模式
英文:

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();

huangapple
  • 本文由 发表于 2023年8月8日 23:25:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76861012.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定