javaimage-uploadfilestack

How to tell if a file has already been uploaded to Filestack (Java)


I have a simple command line tool that fetches preview images from a remote location and uploads to Filestack every time it runs, even if the images had been uploaded in previous runs. Is there a standard way I can check if a file already exists in Filestack before attempting an upload?

Options I'm considering:

One option would be to make HTTP HEAD request to the potential Filestack file URL, but AFAIK that's only possible if I have the Filestack image handle/key from the previous run.

The other option would be to :

  1. Store preview image id <> Filestack handle/key in a serializable map every time a new image is uploaded
  2. Serialize the map when the run is done
  3. At the beginning of the next run deserialize the map so I have an idea of was uploaded.

I just want to know if there's a better or Filestack(standard) way of doing this other than the options I'm considering.


Solution

  • Did a bit of research and it seems with Filestack there's no way to check if a file was uploaded unless the file handle/key is known as I stated earlier. So I settled for the second approach which is to store a key/value map of resourceId and file URL locally, then use object serialization and deserialization technique to preserve state and it works pretty well. here are the steps

    1. Add resourceId <> Filestack handle/key to a serializable map every time a new image is uploaded
    2. Serialize the map when the current run is done
    3. At the beginning of the next run deserialize the map so you have an idea of has already been uploaded.