If I understand you correctly, what you are trying to do is to upload a file to a server using the URL of the file directly on Postman.
This is an interesting use case, but I do not think Postman currently supports it.
Ideally, when you upload a file using form-data
or binary
over an HTTP request, what you send is a blob
or a base64
string of the file. Postman makes this more convenient by allowing you to select a file locally and does the conversion for you when you make a request.
I am guessing that you are using this file in an automation flow which is why you want to avoid downloading it locally?
My solution might be quite hacky but it works. It involves you first converting the file to base64
when it is fetched, then you save this in your environment. You can then retrieve this base64
string from your environment when you want to upload it.
- Create an environment for this and add a convenient variable name. In my case, I used
filebase64
.
- Send a
GET
request to the image and add some postman scripts to theTest
tab which runs after the file has been fetched. The script simply gets thebase64
of the file using thedataURI
method and saves it in the environment.
const image = pm.response.dataURI()
pm.environment.set("filebase64", image);
NOTE: Don’t forget to toggle the right environment by the top right.
Now, each time you fetch a file, it gets the base64
equivalent text of that file and saves it as an environment variable.
Post
thebase64
text saved in your environment to your server.
You will notice that this base64
text is in the echoed response, which means it got sent.
I created a public collection for this example. You can check it out here.
Let me know if it works for you!