How to get the UTC date for when an image was uploaded using Images.get()?

92 views Asked by At

I am writing a plug-in to export/sync data from DroneDeploy.

I looked at the JSON that is returned from Images.get(). Sometimes a "date_creation" field is available. Sometimes that field is not present. Furthermore, within this field, a "$date" field shows what looks like a string based date which I have to assume is a local date? Is the representation of that date the local time of the user who uploaded the image? Or has it already been converted to the time zone of the user currently logged in?

Sample snipped JSON of an image coming from the Images.get() API:

{
    "name": "camera",
    "drone_session_id": "1495472258_SUPPORTOPENPIPELINE",
    "command": "log",
    "drone_device_id": "1495472258_SUPPORTOPENPIPELINE",
    "date_creation": {
        "$date": "2017:02:09 11:37:46"
    }
}

How can I get a reliable true UTC date of when this image was uploaded to DroneDeploy so I can determine whether or not I should export the image if a user comes back and requests another sync operation to occur?

1

There are 1 answers

3
Dan Rasmuson On

The image exif information you are referring can be a little unreliable due to which camera capture the images.

In order to determine which images you should sync I would recommend looking at which plans you have and haven't synced.

I.E.

const allPlanIds$ = dronedeployApi.Plans.all().then((plans) => plans.map((plan) => plan.id));
const alreadySyncedPlanIds$ = fetch()... // get these planIds from your server
const planIdsToSync$ = Promise.all(allPlanIds$, alreadySyncedPlanIds$).then(([planIds, syncedPlanIds]) => planIds.filter((planId) => !syncedPlanIds.includes(planId)));
planIdsToSync$.then((planIdsToSync) => console.log(planIdsToSync)) // get images for these planIds