Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: preview.info #40

Closed
igorsheg-wix opened this issue Nov 25, 2018 · 6 comments
Closed

API: preview.info #40

igorsheg-wix opened this issue Nov 25, 2018 · 6 comments
Labels
question Further information is requested

Comments

@igorsheg-wix
Copy link

Hey,

I'm trying to get the preview to work - to get an png of a layer.

I'm using preview.info

Getting https://previews.goabstract.com/projects/eda68300-e1d0-11e8-8133-0b70a3eae7f0/commits/51bf03f17a6234d6f703b86d2309fe5ae4a28034/files/D06C3330-664C-4F89-B8E6-AC27B93AF4DC/layers/4DF3A97D-3F66-48A1-9459-B42B3154391C

then when i try to access it I get {"error":"forbidden"}

maybe the documentation is unclear or I got something wrong.

Thanks in advance!

@igorsheg-wix igorsheg-wix changed the title Preview API API: preview.info Nov 25, 2018
@tommoor
Copy link
Contributor

tommoor commented Nov 25, 2018

Hey Igor, short answer is – use previews.raw to get the data and save it somewhere. The previews service requires authentication with a token which would have to be saved with the URL.

We're looking into how this can be improved (perhaps with a previews specific short-lived token) as we realize it's not as developer friendly as it should be.

@tommoor tommoor added the question Further information is requested label Nov 25, 2018
@igorsheg-wix
Copy link
Author

@tommoor Hey Tom, can you tell me why some preview.raw do return an array buffer, and some request return Error: Received status "404", expected 2XX [1] at AbstractAPI.fetch (/Users/igors/Development/ux-feed/node_modules/abstract-sdk/lib/AbstractAPI/index.js:294:13) [1] at process._tickCallback (internal/process/next_tick.js:68:7) [1] undefined

Thanks a lot.

@tommoor
Copy link
Contributor

tommoor commented Dec 3, 2018

If you're receiving a 404 it means that the preview does not exist on the server.

There isn't a preview on the server for every commit, for efficiency we only store previews on commit where a layer has changed… so you may need to query the layer.info, and then use layer.lastChangedAtSha to find the last commit where the layer was altered – there should reliably be a preview for these commits.

@amccloud
Copy link
Contributor

amccloud commented Dec 3, 2018

@igorsheg-wix you should also be able to pass sha: "latest" in the descriptor:

previews.raw({...layerDescriptor, sha: "latest"})

https://sdk.goabstract.com/docs/reference/#retrieve-a-preview

@tommoor this is really only documented in a code comment in the docs. I want to add a "Retrieve the latest preview" section to the docs but it would also be nice to have place to generally surface the concept of "latest" across all objects

@tommoor
Copy link
Contributor

tommoor commented Dec 3, 2018

you should also be able to pass sha: "latest" in the descriptor

Ah, of course 🙈 – should have mentioned that too.

@igorsheg-wix
Copy link
Author

@tommoor @amccloud Thanks guys ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants