mardi 27 janvier 2015

AWS S3 getObject causing inabily to open save file for writing

I am using the following Amazon AWS S3 class -


I have over hundreds of images in a bucket. I would like to download each image one by one onto my server. Create its thumbnail, rename it, and upload it to the same bucket. I used the following code:



$s3 = new S3(AWS_ACCESS_KEY_S3, AWS_SECRET_KEY_S3);

// Get the contents of our bucket
$fileNames = $s3->getBucket('bucket-name');

foreach ($fileNames as $fileName){
$fileSource = $fileName['name'];
}


The above code get the list of files in the bucket and it works fine.


In order to download the images I use the following code in the foreach loop:



$s3->getObject('bucket-name', $fileSource, $fileDestination);


This works fine too.


If I run the code once it works seamlessly, but If I run it twice i.e. after say twice after the few seconds I get the following error in my error_log -


PHP Warning: S3::getObject(bucket-name, FILENAME): [0] Unable to open save file for writing: FILENAME in S3.php on line 363.


When I try doing this instead of getObject copy($fileSource, $fileDestination);


I get the following error failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found





Aucun commentaire:

Enregistrer un commentaire