Middleware for requesting a PDF file in a get request #1355
-
Hey I'm contributing to a rails api project that uses faraday for standardizing service requests to third party endpoints. I'm looking for some insight on what middleware is needed when requesting a PDF file in a GET request or what the connection block should look like. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
You can navigate the documentation site for specifics, BUT one thing that you may find is that your request retuns a redirect (an HTTP status in 3xx series), and you'd like the redirect to be automatically "followed". There's a specific FollowRedirects middleware for this, making a redirected URL seamless, a bit like a Web browser works. Hope this inspires you to find the stuff you are looking for! |
Beta Was this translation helpful? Give feedback.
-
@bradbergeron-us to my knowledge, we don't currently have a specific middleware that takes care of this scenario. Do you happen to have a |
Beta Was this translation helpful? Give feedback.
-
Hey @bradbergeron-us, sorry for the late reply, the last few days have been really busy with the Faraday v2 release! I'm glad to hear you're now able to complete the request and you're getting the binary data as expected. There are several options available, below are some:
If you don't need to reference this file in future, then the last option is the best one if you ask me, as you won't have to handle an ever-growing file system on your server 😄 |
Beta Was this translation helpful? Give feedback.
Hey @bradbergeron-us, sorry for the late reply, the last few days have been really busy with the Faraday v2 release!
I'm glad to hear you're now able to complete the request and you're getting the binary data as expected.
However I'm afraid that's pretty much as far as Faraday can help you with.
Now that you got the information you need, it's up to you to decide what to do with it.
There are several options available, below are some:
If you don't need to reference this file in future, then the last …