A quick help here, i wan to achieve an upload of my images to my amazon S3 bucket, i'm able to achieve that with following code.
在这里快速帮助,我想实现我的图像上传到我的亚马逊S3桶,我能够通过以下代码实现这一点。
s3Client = new AmazonS3Client( new BasicAWSCredentials( getString(R.string.s3_access_key), getString(R.string.s3_secret)));
//params contains file path
//PutObjectRequest por = new PutObjectRequest( getString(R.string.s3_bucket), params[0].getName(), params[0]);
PutObjectRequest por = new PutObjectRequest( getString(R.string.s3_bucket), params[0].getName(), params[0]);
s3Client.putObject(por);
ResponseHeaderOverrides override = new ResponseHeaderOverrides();
override.setContentType( "image/jpeg" );
urlRequest = new GeneratePresignedUrlRequest( getString(R.string.s3_bucket), params[0].getName() );
urlRequest.setExpiration( new Date( System.currentTimeMillis() + 3600000 ) ); // Added an hour's worth of milliseconds to the current time.
urlRequest.setResponseHeaders( override );
There is a folder in my bucket I'm not able to upload images to that folder.
我的存储桶中有一个文件夹,我无法将图像上传到该文件夹。
what i tried for uploading images to folder
into bucket is this
我试图将图像上传到文件夹到桶中的是这个
PutObjectRequest por = new PutObjectRequest( getString(R.string.s3_bucket), params[0].getName(), params[0]).withKey("testmorya/");
s3Client.putObject(por);
BUCKET NAME : morya FOLDER NAME : testmorya
BUCKET NAME:morya FOLDER NAME:testmorya
Help appreciated
帮助赞赏
1 个解决方案
#1
8
It is all about how you structure your key. To put "filea" into "folderb", just name the key of the object as "folderb/filea".
这完全取决于你如何构建你的密钥。要将“filea”放入“folderb”,只需将对象的键命名为“folderb / filea”。
#1
8
It is all about how you structure your key. To put "filea" into "folderb", just name the key of the object as "folderb/filea".
这完全取决于你如何构建你的密钥。要将“filea”放入“folderb”,只需将对象的键命名为“folderb / filea”。