由网友(南巷悠长)分享简介:是否有可能上传一个动作一个TXT / PDF / PNG文件到Amazon S3,并获取上传的文件URL作为响应。如果是这样,则AWS Java SDK的正确的库,我需要在我的Java web应用Struts2的增加。Is it possible to upload a txt/pdf/png file to Ama...
是否有可能上传一个动作一个TXT / PDF / PNG文件到Amazon S3,并获取上传的文件URL作为响应。如果是这样,则AWS Java SDK的正确的库,我需要在我的Java web应用Struts2的增加。
Is it possible to upload a txt/pdf/png file to Amazon S3 in a single action, and get the uploaded file url as response. If so, is AWS Java sdk the right library that i need to add in my java struts2 webapplication.
请建议我一个解决方案。
Please suggest me a solution for this.
推荐答案
要上传,您可以使用 PutObjectRequest :
To make the file public before uploading you can use the #withCannedAcl
method of PutObjectRequest
:
myAmazonS3Client.putObject(new PutObjectRequest('some-grails-bucket', 'somePath/someKey.jpg', new File('/Users/ben/Desktop/photo.jpg')).withCannedAcl(CannedAccessControlList.PublicRead))
相关推荐
最新文章