Amazon AWS - PHP: Create a new text file inside a bucket.
This snippet demonstrates how to use the create_object API.
In this case, we create a new text file, filling it up with some text.
Taken from: http://www.sitepoint.com/getting-started-with-the-aws-php-sdk/
post this code
$s3 = new AmazonS3();
// Create Object is pretty self explanatory:
// Arg 1: The bucket where your file will be created.
// Arg 2: The name of your file.
// Arg 3: An array of Options.
// In this case we're specifying the "body" option
// and the ACL setting to allow this file to be read by anyone.
$response = $s3->create_object('MyBucketName', 'newtextfile.txt', array(
'body' => 'Hello world. Nice to meet you.',
if ((int) $response->isOK()) echo 'I Created a File!';
If you want to be updated about similar snippets,
and follow our Channels