Guest User

Untitled

a guest
Jul 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. require("aws.phar");
  2. use AwsS3S3Client;
  3. use AwsS3ExceptionS3Exception;
  4.  
  5. $bucket = 'my bucket';
  6. $filepath = 'currentfilepath.jpeg';
  7. $filename = 'newfilename.jpeg';
  8.  
  9. $s3 = S3Client::factory(array(
  10. 'key' => 'XXX',
  11. 'secret' => 'YYY',
  12. 'region' => 'eu-west-2',
  13. 'version' => 'latest'
  14. ));
  15.  
  16. try {
  17. $result = $s3->putObject(array(
  18. 'Bucket' => $bucket,
  19. 'Key' => $filename,
  20. 'SourceFile' => $filepath,
  21. 'ACL' => 'public-read'
  22. ));
  23. var_dump($result);
  24. } catch (S3Exception $e) {
  25. echo $e->getMessage() . "n";
  26. }
Add Comment
Please, Sign In to add comment