Re: how to upload a file using Amazon S3? - stream() or save() ?
| From: | Christian Schmidt | Date: | Tue, 19 Aug 2008 20:59:20 +0000 |
| Subject: | Re: how to upload a file using Amazon S3? - stream() or save() ? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-29181@lists.php.net to get a copy of this message | ||
l Burnerheimerton wrote:
In order to save a file to your bucket on S3, do you use Class: Services_Amazon_S3_Resource save() method or stream()? You can save a file to S3 using the following piece of code:$accessKeyId = '0PN5J17HBGZHT7JJ3X82'; $secretAccessKey = 'uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o'; $s3 = Services_Amazon_S3::getAccount($accessKeyId, $secretAccessKey); $bucket = $s3->getBucket('mybucket'); $object = $bucket->getObject('foo.txt'); $object->data = 'lorem ipsum dolor sit amet'; $object->save(); Alternatively you can use the stream wrapper and use regular file handling functions: Services_Amazon_S3_Stream::register('s3', array(
'access_key_id' => '0PN5J17HBGZHT7JJ3X82',
'secret_access_key' => 'uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o'));
file_put_contents('s3://mybucket/foo.txt', 'lorem ipsum dolor sit amet');
Christian