by
8,522 33
0
5
2,533
0
Top 1% !
Popular
Famous
Specified
OpenSource
Popularity: 5695th place
Created
Modified Jul 23, 2013

Published on:

No tags for this snippet yet.
Extension.php
LanguagePHP
LicenseMIT_X11
Target Frameworkaws

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/
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/4456/Amazon-AWS---PHP--Create-a-new-text-file?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
<?php require_once 'sdk.class.php'; $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 &quot;body&quot; 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.', 'acl'=>AmazonS3::ACL_PUBLIC, )); if ((int) $response->isOK()) echo 'I Created a File!'; ?>
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus