我發現這個http://knplabs.com/blog/give-your-projects-a-gaufrette如何使用Gaufrette將圖像上傳並存儲到S3中而不使用捆綁包?
,並提供了代碼示例是
<?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
但答案似乎傾向於使用Gaufrette束爲symfony1.2傾斜。
我沒有使用Symfony,所以我希望有一個很好的例子,我可以通過Gaufrette將圖像上傳到S3。
謝謝。
而不是'有些內容',你可以把變量,代表你的形象。 你如何獲得圖像? 如果它是由用戶上傳的,您可以在$ _FILES中找到它,並使用提供的臨時文件名,您可以使用file_get_contents將其讀入到PHP變量中。 –
抱歉。我實際上已經遠離了最後使用吹風機。我認爲你的答案是正確的。 –