Download file when send request

Hi guys,
Now I have an interface which use to download file. Is there any way to download file when I send the request but without click [Send and download] button ? For example, can I do this with writing some code in the ‘Test handling’ area or other programming way ?

1 Like

@su.ziying https://documenter.getpostman.com/view/3407886/RWgp1fB5

I am not able to open the attached link it is throwing 404 error . I have similar requirement can you please help.

Weird, the link isn’t giving 404 for me.

But anyway, Just go to the app click on “New” > “Templates” > Search for “Write Response” and use that template by clicking “Run in Postman”.

The template has all the instructions that will be required.

Its not working with octet stream what can we do to complete that.

This requires starting up an external (outside of Postman) NodeJS app first.

Is there any way to do this within Postman (i.e. on the Test or Pre-request Scripts Tab)? (It doesn’t seem so, since the Postman script sandbox doesn’t supply the NodeJS file library.)

1 Like

Hi @bharat.r,

Can you show us a screenshot of the octet stream you are getting back? If its base64 encoded, you can use Postman Visualizer to create a “web page” where you set the value of the window.location.href = "yourBase64OctetStream" in your visualizer template, which should initiate a download.

Granted, depending on what the file is, your operating system might not know how to open the file. If you can specify the file type, such as ‘application/pdf’, it should save as the proper file format, and then can be opened without the OS having to guess what it is.

Hope this helps!

Best,
Orest

@singhsivcan Hi, i have similar issue facing i.e not able to download .wav or mp3 format via collection. I am running a collection which is able to download the content (as symbols) however i would need to get in .wav file to play the audio. For this to work send with download when run the collection . Could you assist me what changes required in order to send with download work?

Govinda

1 Like