AWS PHP SDK – UploadSyncBuilder Uploads files already present remotely

I recently ran into an interesting issue with the Amazon Web Services PHP SDK, when using UploadSyncBuilder, as described in this section of the AWS documentation. The problem was that in some cases, Amazon cares about leading / characters, and other cases they do not matter.

For example, assume you are uploading a file with the following key: /myFiles/myLargeFile.txt. Amazon will effectively remove the beginning slash, and store that object as simply myFiles/myLargeFile.txt. This becomes problematic when using the UploadSyncBuilder as it relies on Aws\S3\Sync\ChangedFilesIterator. ChangedFilesIterator will do a string comparison of your local object key name with those remotely on S3. This means that it will assume, incorrectly, that the object ‘/myFiles/myLargeFile.txt’ does not exist because it does not exactly match ‘myFiles/myLargeFile.txt’.

If you use UploadSyncBuilder, and you find your finds being reuploaded regardless of if they are on the server, make sure you check that the local and remote keys match!

Posted February 11th, 2014 in Uncategorized. Tagged: , .

Leave a response: