0

Create new file .txt or .json on Amazon s3 using aws sdk php

In this tutorial, we will see ‘how to¬†create file on Amazon s3 using php’.
Before using the following script, you must installed aws sdk php.

$s3 = \Aws\S3\S3Client::factory(array(
'key' => 'YOUR_ACCESS_KEY',
'secret' => 'YOUR_KEY_SECRET',
));
$s3->registerStreamWrapper();
$stream = fopen("s3://YOUR_BUKCET/index.json", 'w', false, stream_context_create(array(
's3' => array(
'CacheControl' => 'no-cache',
'ACL' => 'public-read',
)
)));
fwrite($stream, "content of index.json");
fclose($stream);

Ambar Hasbiyatmoko

Hello, I'm web developer. Passionate about programming, web server, and networking.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.