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

404 attempting to programmatically download file from asset url #227

Closed
cody-lettau opened this issue Jul 14, 2020 · 2 comments
Closed

404 attempting to programmatically download file from asset url #227

cody-lettau opened this issue Jul 14, 2020 · 2 comments

Comments

@cody-lettau
Copy link

I am receiving a 404 error whenever I attempt to download an asset from the URLs provided after creating a postcard.

I have tried using request, node-fetch, axios, and the standard https package in node. My goal is to download the assets (postcard thumbnails and the PDF proof) and upload them to an AWS S3 bucket. I would like to stream the response from the GET request to the PUT so I do not need to store the files on disk temporarily.

Is there any advice on how I can get this to work? I have no issues when using Postman, but for some reason, I am getting 404s when attempting from my server-side node application.

@dmlittle
Copy link
Contributor

@cody-lettau thanks for opening up an issue, I can see how this can be frustrating. I see you've closed the issue so hopefully you've managed to resolve the issue; if you haven't, here's a little bit more information about our rendering process.

Our rendering pipeline is asynchronous; while we return a signed URL to the location the asset will ultimately live at it may not have been generated by the time you fetch. Typically we see our rendering process take about 1-2 seconds although a few edge cases might cause our process to take longer. The best way to know when the assets have been rendered is to listen to our webhook events. We send a postcard.rendered_pdf event for each postcard once it's been successfully rendered. A less complex solution that might fail in some edge cases is to wait 2-3 seconds after you receive the response from Lob's API to download the assets. This is why Postman seems to work, the manual steps take long enough for our rendering process to finish by the time you download the asset.

@cody-lettau
Copy link
Author

@dmlittle - Thanks for the quick response! The asynchronous rendering was what was throwing me off. I ended up implementing a timeout for now, but I do plan to switch over to use the webhook in the future as that would be cleaner.

Again, thanks for the quick reply. I literally just got it all working a few hours ago!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants