Ankit_pastebin

Untitled

Feb 20th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. $filename='group_image'.$group_id.'.jpg';
  2.  
  3. // save image in output Buffer --
  4. ob_start();
  5. imagejpeg($outputImage,NULL,100);
  6. $imageFileContents = ob_get_contents();
  7.  
  8. // header('Content-Type: image/png');
  9. // imagepng($imageFileContents);
  10.  
  11. // use AwsS3S3Client;
  12. $directory = 'uploads/images/'.$filename;
  13.  
  14. // Create an Amazon S3 client object
  15. $client = S3Client::factory(array(
  16.  
  17. 'secret' => 'RtzcCuO2yLnHWtFpjcpNaPHdFKhI4QfaICSngw4q',
  18. 'key' => 'AKIAJAJRA6ZVHKUBHW7A'
  19. ));
  20.  
  21.  
  22. $context = stream_context_create(array(
  23.  
  24. 's3' => array(
  25. 'ACL' => 'public-read'
  26. )
  27. ));
  28.  
  29. // Register the stream wrapper from a client object
  30. $client->registerStreamWrapper();
  31.  
  32. $bucket = 'momentsbucket';
  33. $key = $directory;
  34.  
  35. // save content on S3 --
  36. $contents = file_put_contents("s3://{$bucket}/{$key}",$imageFileContents,0,$context);
  37.  
  38. $size = filesize("s3://{$bucket}/{$key}");
  39.  
  40. ob_end_clean(); // clear o/p buffer
Add Comment
Please, Sign In to add comment