Reputation: 10822
I found this http://knplabs.com/blog/give-your-projects-a-gaufrette
and the code sample it provides is
<?php
$amazon = new AmazonS3('myKey', 'mySecretKey', 'myToken');
$adapter = new Gaufrette\Adapter\AmazonS3($amazon, 'my_bucket');
$filesystem = new Gaufrette\Filesystem($adapter);
if ( ! $filesystem->has('foo')) {
$filesystem->write('foo', 'Some content');
}
echo $filesystem->read('foo');
This does not appear to be writing an image file.
I also found Gaufrette upload image and store in AmazonS3
but the answer appears to be leaning towards using Gaufrette bundle for Symfony.
I am not using Symfony, so I am hoping for a good example I can use to upload images to S3 via Gaufrette.
Thank you.
Upvotes: 1
Views: 4597
Reputation: 37378
Your example writes the text "Some content". Instead of that you could put your image content.
$imageData = file_get_contents('/tmpupload/picture.jpeg');
$filesystem->write('foo', $imageData);
You should also write the images mime type to amazon/gaufrette. If i am not mistaken, this should work:
$filesystem->write('foo', $imageData, ['content-type' => 'image/jpeg']);
Upvotes: 2