Post a file from a URL

My question:

I’m successfully sending local binary files from my computer to an endpoint. What I’d look to do however, is send files which are not stored locally, but available on a CDN, and deposit them into another endpoint.

Business Scenario: I have a DAM with thousands of assets, I want to take a list of assets available on a CDN, that are related to a particular client, and send just those renditions to a clients. I will export a list of URLs, and then use postman to send the contents of the URL directly to the endpoint.

What I’d like to avoid: I do not want to download all of the files locally, and then transmit to the end point. This would be slow, and heavy transfer since we could be talking about 10,000s+ files.

Example: Instead of having this image on my computer and putting it in the Body of the post as a binary, I want to just insert this URL: https://upload.wikimedia.org/wikipedia/en/8/89/GordonShumway.png
Send this image to an endpoint with authorization.

Let me know if this is possible!

Thanks

welcome to postman community :tada: could you add some example API so that i can try it out

Hi! This question is actual for me, too.

I need to POST in 1 request body (JSON) simultaneously:
key1: string
key2: string
key3_url: string, link to file saved on some external website.[PDF]

Is it possible to do?
If yes, what about the correct content type setting in headers?

Hey @andrei.alex.rodin and @geoffbarrenger, Welcome to the community :tada:

I think for now, you can just send out the link within your JSON body.

Also, to make your scenario work, here are some suggestions:

  1. POST a URL within the JSON body, and the destination endpoint should have the mechanism to parse the URL and download the content (which can be images/pdf).
  2. Using Postman’s pre-request script:
    • Download the content from URL.
    • Convert it to binary
    • Assign the binary value to a dynamic variable
    • Use the variable within your request.
  3. Using Postman’s Runner: (feasible for few requests)

Cheers :smiley:

Thanks a lot!
Scenario 1 doesn’t work (the endpoint throws error 400).
So, as the task condition assumes only 1 request, only Scenario 2 is the right answer for me :+1:

1 Like

@andrei.alex.rodin Are you able to share your code for the pre request script you used? I’m trying to do something similar