filestack / filestack-java

Official Java SDK for Filestack - API and content management system that makes it easy to add powerful file uploading and transformation capabilities to any web or mobile application.
https://filestack.com
Apache License 2.0
18 stars 18 forks source link

Unable to retrieve S3 Key String #83

Closed PGMacDesign closed 5 years ago

PGMacDesign commented 5 years ago

I am using the upload method as mentioned here and successfully uploading an image to FileStack. As per the sample code here, I am able to retrieve the handle String. The problem is that we have things auto-configured so that the code will auto upload to the S3 bucket and I need to retrieve the S3 key from the response.

When our server uploads an image, they go through the pick and store flows and eventually retrieve back this response:

{
  "client": "computer",
  "container": "mycompany-products-development",
  "converted": true,
  "filename": "Image.png",
  "id": 1,
  "isWriteable": true,
  "key": "media_embeds/uploads/q12VsskeFtcxItJzYRm9_Image.png",
  "mimetype": "image/png",
  "size": 87970,
  "url": "https://www.filepicker.io/api/file/B2B3FFWWSvuopHofinML"
}

(Note that I changed the characters to mask our original image)

Which clearly has the handle at the suffix of the url, but it also includes a Key, which is what I need to obtain.

How do I go about obtaining this key with only the handle to work with? Can it be done by chaining different methods in the Java SDK? Or is there a way to convert it somehow into the key I need?

PGMacDesign commented 5 years ago

After a good amount of trial and error, it looks like there is no SDK solution for this.

I ended up creating a mini SDK (single call) to interact with this endpoint -- https://www.filestack.com/docs/api/file/#md-request

From there, I would get back the handle String and send it to this code and receive back the metadata.

That metadata contains all of the parts to build / create the S3 URL link by combining the container + path + regular S3 url schema.

PGMacDesign commented 4 years ago

Sigh. If anyone implemented my solution here between May 15 and October 2019, the dev team updated the base URL and broke the old entirely without any notice whatsoever. image

Switch to the new API URL: https://www.filestackapi.com to get the code working again.