MikaelW
MikaelW

Reputation: 1205

Amazon S3 getDate() API Call?

Is there a way (API call) to know the current time on an Amazon S3 server?

Here is a bit of background to explain why I need this:

I have an iphone app that sometimes has to download a set of files from a bucket on a Amazon AWS S3 account.

Between two such downloads, the server files may be modified by a CMS (Web Content Management System), or not.

So, when a second download occurs, The client app tries to be efficient by downloading only the files that have been modified on the server since the previous such download.

To achieve this, the app stores the date of the last download and when a new download occurs, it just focuses on the files that have been modified on the server since the date of the last download (using there “modified date” property accessible using the SDK listObjects() function).

The problem with this is that the date on the phone and the modified dates on the s3 server may not be compatible. The phone user may have changed his phone date & time settings, etc.

To make this work, the saved “last download date” should come from an Amazon S3 API call to make sure all dates used by the app logic are in sync.

Is there such thing? Or maybe an alternative or a workaround?

Upvotes: 2

Views: 195

Answers (1)

s.bandara
s.bandara

Reputation: 5664

You could use a file hash instead of the modified date. An Amazon S3Object has an etag property that is indeed such kind of hash. You retrieve this property the same way as you access date.

Have your client device save this hash along with the file. The next time you connect to the server, ask for the etag using the method about and compare the returned value to your local copy.

A different etag value will indicate to the client that the file has changed since the last download. This approach would be completely independent of any datetime functionality.

Upvotes: 4

Related Questions