I am developing an iPhone app to allow user upload photo and share. I want to use S3 to store uploaded images as well as processed images (foe example, thumbnail, reduced size image). I've installed AWS PHP SDK on my EC2 instance, my questions are: 1) Should photos uploaded from iPhone app go to a EC2 directory first, then copied over to S3 bucket, or it should directly uploaded to S3? 2) How can I create different folders under the S3 bucket through PHP SDK and how to read the files from the folder?
Thanks in advance!
You can use the CloudFormation template in the following resolution to use custom resources with an S3 bucket. Consider the following: The template allows you to create folders in S3 buckets. Amazon S3 has a flat structure, but supports the folder concept as a means of grouping objects.
S3 doesn't have a folder structure, But there is something called as keys. We can create /2013/11/xyz. xls and will be shown as folder's in the console. But the storage part of S3 will take that as the file name.
To upload folders and files to an S3 bucket Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ . In the Buckets list, choose the name of the bucket that you want to upload your folders or files to. Choose Upload.
Yes , it is possible to create new folder using s3
sdk.
try bellow code
<?php
/* abc is the folder name */
$s3->putObject(array(
'Bucket' => $bucket,
'Key' => "abc/",
'Body' => "",
'ACL' => 'public-read'
));
The answer can be found here: Direct upload to s3 without the use of a production server
I've never used the PHP SDK, but I was browsing through the AWS SDK for PHP 1.5.14 documentation and came across the following APIs that you will need to utilize:
a) create_object : You'll use this to put a object into a bucket. You'll specify the filename. You asked how you can create different folders: you will include the full path into the filename. For instance instead of naming the file "photo1.jpg", you would name it "user1/vacation/photo1.jpg".
b) get_object_list : This API will return to you a list of objects given some criteria. If you want to read all the objects from a particular folder, specify the prefix as the path to the folder. For instance, if I want to find all files in the folder "user1/vacation/", I would specify my prefix to be "user1/vacation/".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With