TAGS :Viewed: 28 - Published at: a few seconds ago

[ AWS S3 Bucket - Add file to inner folder using AWS SDK ]

How can we add a file to an inner folder in a bucket? If there is a bucket named user --> i want to add it to the folder images/selected/ . Please help.

Answer 1


This is what I do to upload a local file (localfilename.txt) to S3 and place files in 'folders' (image/selected/s3filename.txt).

AmazonCredentials * credentials = [[AmazonCredentials alloc] initWithAccessKey:ACCESS_KEY_ID withSecretKey:SECRET_KEY];
putObjectRequest = [[[S3PutObjectRequest alloc] initWithKey:@"images/selected/s3filename.txt" inBucket:@"user"] autorelease];
[putObjectRequest setFilename:@"localfilename.txt"];
[putObjectRequest setCredentials:credentials];
[[AmazonClientManager s3] putObject:putObjectRequest];

Hope this helps. Cheers, Trond