0
當我使用這個函數來創建特定的鏈接它不是直接 顯示刷新後的圖像則顯示無法看到圖像直接需要刷新
http://mysite.local/img/slide-image-321.jpg/369x360
時的鏈接圖片
private function generate_cache($localpath, $from, $to, $width, $height) {
$tempFrom = pathinfo($from);
$tempTo = pathinfo($to);
$tempPathFrom = $localpath.$tempFrom['basename'];
$tempPathTo = $localpath.$tempTo['basename'];
// Amazon S3
$awsAccessKey = Zend_Registry::getInstance()->config->amazons3->awsAccessKey;
$awsSecretKey = Zend_Registry::getInstance()->config->amazons3->awsSecretKey;
$bucketName = Zend_Registry::getInstance()->config->amazons3->bucketName;
$s3 = new Zend_Service_Amazon_S3($awsAccessKey, $awsSecretKey);
// ..
if(file_get_contents('http://'.$bucketName.'.s3.amazonaws.com/'.$tempFrom['basename'])) {
$content = file_get_contents('http://'.$bucketName.'.s3.amazonaws.com/'.$tempFrom['basename']);
}
if(!file_put_contents($tempPathFrom, $content)){
echo "Failed to copy the file";
}
$resize = $this->_helper->imgResize($tempPathFrom);
$resize->resizeImage($width, $height);
$resize->saveImage($tempPathTo, 95);
if(!$s3->putFile($tempPathTo, $bucketName."/".$tempTo["basename"])){
echo "failed to put the resized image in s3";
} else {
// Deleting the local files
unlink($tempPathTo);
unlink($tempPathFrom);
}
}
(不Amazon S3的)其工作正常,問題出在S3中,我不知道如何解決它 \t私有函數generate_cache($來自$到,$寬度, $ height){ \t \t $ resize = $ this - > _ helper-> imgResize($ from); \t \t $ resize-> resizeImage($ width,$ height); \t \t $ resize-> saveImage($ to,95); } – 2012-07-17 13:31:20
不知道我向你展示了正確的方法,但是在嘗試s3時,可能需要一些時間來處理圖像,如果它在服務器本身上,圖像將被瞬間處理。 – Jithin 2012-07-18 05:53:42