Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require("aws.phar");
- use AwsS3S3Client;
- use AwsS3ExceptionS3Exception;
- $bucket = 'my bucket';
- $filepath = 'currentfilepath.jpeg';
- $filename = 'newfilename.jpeg';
- $s3 = S3Client::factory(array(
- 'key' => 'XXX',
- 'secret' => 'YYY',
- 'region' => 'eu-west-2',
- 'version' => 'latest'
- ));
- try {
- $result = $s3->putObject(array(
- 'Bucket' => $bucket,
- 'Key' => $filename,
- 'SourceFile' => $filepath,
- 'ACL' => 'public-read'
- ));
- var_dump($result);
- } catch (S3Exception $e) {
- echo $e->getMessage() . "n";
- }
Add Comment
Please, Sign In to add comment