Creating a S3 bucket

Bucket name This name will be part of the url of objects stored in the bucket, e.g. https://s3-eu-west-1.amazonaws.com/mybucketname/myfile.jpg Public read access You can set this to not public and still mark objects in the bucket as publicly readable as they are stored. Users Just the main AWS account holder / you is fine. Creating a user […]

Read More

.S3 General

Get AWS SDK Simple include the SDK .phar method  Download the "aws.phar" file and store it in a subdirectory called, says awssdk.  Then in your php files use: require 'awssdk/aws.phar'; Define your S3 access values ready to use in your code $AwsS3BucketName = ''; //<<<<SET THIS $AwsS3AccessKeyId = ''; //<<<<SET THIS $AwsS3AccessSecretKey = ''; //<<<<SET […]

Read More

Upload A Server File

This uses an old aws method Upload A Saved File $upload_file = if (file_exists($upload_file)) { try { $options = array('key' => $s3_accesskey, 'secret' => $s3_secretkey); $s3 = new AmazonS3($options); //Upload file $response = $s3->create_object($s3_thumbnails_bucket, basename($upload_file), array( 'fileUpload' => $upload_file, //'storage' => AmazonS3::STORAGE_REDUCED, 'acl' => AmazonS3::ACL_PUBLIC )); if ($response->isOK()) echo "Upload success"; else echo "Upload failed"; […]

Read More

Rename Object

You can’t rename objects in S3, you have to copy them to a new object name and then delete the original //—– SET THE FILE NAME EXTENSION TO MATCH THE USER UPLOADED FILE —– require_once ‘my_sdk_files_path/sdk.class.php’; //<<<<SET THIS $s3 = new AmazonS3(); $bucket = “my_bucket_name”; //<<<<SET THIS //GET THE USERS FILENAME EXTENSION $filename_extension = pathinfo($uploaded_source_file_name, […]

Read More

Upload A File From A Form

Basic Upload With Page Hanging Until Upload Completes <?php include_once('config.php'); require 'awssdk/aws.phar'; //<SDK so we can access S3 storage global $AwsS3BucketName; global $AwsS3AccessKeyId; global $AwsS3AccessSecretKey; $sdk = new Aws\Sdk([ 'version' => 'latest', 'region' => 'eu-west-1', //<<<<< REGION 'credentials' => [ 'key' => $AwsS3AccessKeyId, //<<<<< S3 ACCESS KEY ID 'secret' => $Aw if (isset($_POST[‘submit’])) { //—– […]

Read More