xydev
xydev

Reputation: 3409

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.

Upvotes: 4

Views: 2474

Answers (1)

Trond Kristiansen
Trond Kristiansen

Reputation: 2456

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

Upvotes: 6

Related Questions