Thursday, 8 August 2013

Putting multiple objects in Amazon S3 with different meta data fails

Putting multiple objects in Amazon S3 with different meta data fails

I've got an array of file information that is being looped through and
using the AWS PHP 2 skd to upload the contents of these files to the
cloud, it all works brilliantly until I try and add meta data, at this
point, it adds the the metadata to the first object created, but after
that I get the following error message:
Fatal error: Uncaught Aws\S3\Exception\SignatureDoesNotMatchException: AWS
Error Code: SignatureDoesNotMatch, Status Code: 403, AWS Request ID:
8FC9360F2EB687EE, AWS Error Type: client, AWS Error Message: The request
signature we calculated does not match the signature you provided. Check
your key and signing method., User-Agent: aws-sdk-php2/2.2.1 Guzzle/3.3.1
curl/7.24.0 PHP/5.3.13 thrown in
D:\Inetpub\wwwroot\ThirdParty_Resources\AWS_SDK2\aws\aws-sdk-php\src\Aws\Common\Exception\NamespaceExceptionFactory.php
on line 89
I've cropped the code from my loop to highlight the area that is being
naughty.
foreach($aFiles as $aFile) {
$arr_ObjectMeta = array(
'OriginalFileName' => $aFile['FileName']
, 'Description' => $aFile['FileDesc']
, 'Keywords' => $aFile['FileKeyW']
);
// get the file to upload
$obj_FileUpload = $obj_S3->putObject($sBucket, $sBucketFolder .
$sFilenameToSave, $sFile, 'public-read', $arr_ObjectMeta);
if($obj_FileUpload) {
$files_uploaded++;
} else {
$files_not_uploaded++;
}
// clear the file upload S3 response object
unset($obj_FileUpload);
// delete the downloaded file
unlink($sServerUploadFolder.$sFilenameToSave);
}
So the second time around the loop, it seems to bomb because of the
different meta values. When the meta data is the same, the loop executes
without issue. Any help/pointers would be great.

No comments:

Post a Comment