1

Amazon php sdk (http://docs.aws.amazon.com/aws-sdk-php/v3/guide/service/s3-transfer.html) sync operations are performed using the above linked methods. I've successfully coded and configured them, but on each call for the method the last modified date on files under the bucket gets updated to the latest time, given that the files were not modified locally to the previous sync call.

I wonder whether is it a sync operation at all or just overwriting operation of whatever is sent from the local directory?

Why this matters is we are planning to sync gigs of files in between a server and S3 bucket. Using S3 buckets as backup storage, in case of any disruptions we can sync (S3 bucket -> server) the opposite way to make the missing pieces of data available in our server.

Notes:

  1. I've also tried this one from here
  2. Currently I'm using version 3 of the AWS php sdk
Community
  • 1
  • 1
Nasik Shafeek
  • 951
  • 8
  • 17

1 Answers1

4

Unfortunately I believe the answer is no, I also see complete upload of every file when using the Transfer class.

It used to work, from the v2 API docs:

The uploadDirectory() method of a client will compare the contents of the local directory to the contents in the Amazon S3 bucket and only transfer files that have changed.

Perfect, that's what we want!

However, in v3 they have preserved S3Client::uploadDirectory() for API compatibility I guess, but it's just a wrapper for Transfer::promise(), which as we know just uploads without any syncing. Keeping API compatibility but changing behavior like this seems like a really bad idea to me.

I ended up having to add support to my project to use the AWS CLI tool for the actual uploading, which does support sync perfectly. Far from ideal.

If there is a way to use the Transfer class for easy syncing instead of complete uploading, I hope someone can prove me wrong.

chronon
  • 568
  • 3
  • 12