我找到了这个http://knplabs.com/blog/give-your-projects-a-gaufrette
它提供的代码示例是
<?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');这似乎不是在写入图像文件。
我还发现了Gaufrette upload image and store in AmazonS3
但答案似乎倾向于对Symfony使用Gaufrette捆绑包。
我没有使用Symfony,所以我希望有一个很好的例子,我可以用它来通过Gaufrette将图片上传到S3。
谢谢。
发布于 2013-06-05 15:19:28
您的示例将文本写为"Some content“。取而代之的是,你可以把你的图片内容。
$imageData = file_get_contents('/tmpupload/picture.jpeg');
$filesystem->write('foo', $imageData);您还应该将图像的mime类型编写为amazon/gaufrette。如果我没记错的话,这应该是可行的:
$filesystem->write('foo', $imageData, ['content-type' => 'image/jpeg']);https://stackoverflow.com/questions/16032297
复制相似问题