postman-app-support icon indicating copy to clipboard operation
postman-app-support copied to clipboard

Feature request: allow setting through a variable the name of the file to upload

Open josslamberti opened this issue 8 years ago • 10 comments

App Details:

Postman for Windows Version 5.3.0 win32 10.0.15063 / x64

Feature Request:

When a request includes a file to upload, I'd like to be able to set the name of the file through a variable and/or in the pre-request script. Currently, when I set the body to 'form-data' and add a key with the type 'file', the only way to set the file to upload is through the file picker. It would be useful to use an environment variable to set the filename (for example, the API I'm testing requires a new file name for every request to avoid erroneous duplicates).

josslamberti avatar Oct 16 '17 09:10 josslamberti

@josslamberti Thanks for the suggestion! We'll take a look at this.

sdnts avatar Oct 18 '17 11:10 sdnts

may i know the status of this issue? we are in a situation to use this :)

karthiksml avatar Mar 07 '19 09:03 karthiksml

No ETA just yet. We have some work on variable types on our roadmap, so we'll consider this request then.

vkaegis avatar Mar 23 '19 10:03 vkaegis

Would love to see this feature, would save me like an hour of manually dredging through tons of file setting options.

DustinHendrickson avatar Apr 09 '19 19:04 DustinHendrickson

We would love that too !

Also when importing a collection (because we use newman), the path we could set manually in json is removed...

barcooverture avatar Apr 30 '19 13:04 barcooverture

It would be great o see this added. Its been 2 years since the suggestion. Hopefully, it will be added at some point....

levyblue avatar Jan 01 '20 16:01 levyblue

It is actually possible. just export the collection to .json and replace the file path by a placeholder like this.

"formdata": [{
		 "key": "filename",
		 "contentType": "image/jpeg",
		 "type": "file",
		 "src": "{{filePath}}"
		}],

Re import the collection.json back in postman.make sure your files to upload are in your local postman working_directory.

schmitzdenis avatar Feb 11 '20 19:02 schmitzdenis

Hi, @schmitzdenis : Thanks, for the hint. This works only once. But, we wanted to exchange the src-file during runtime, e.g. for iteration.

Chekkov avatar Feb 12 '20 08:02 Chekkov

Not sure to understand the issue then @Chekkov , the filePath will change with any value it's assigned to. So for every iteration of a postman runner, or when you change it with pre-request script at runtime as an example ..

schmitzdenis avatar Apr 27 '20 20:04 schmitzdenis

It is actually possible. just export the collection to .json and replace the file path by a placeholder like this.

"formdata": [{
		 "key": "filename",
		 "contentType": "image/jpeg",
		 "type": "file",
		 "src": "{{filePath}}"
		}],

Re import the collection.json back in postman.make sure your files to upload are in your local postman working_directory.

I have tried but get the same error each time " Form param document, file load error: "pdf", no such file "

code: "key": "document", "type": "file", "src": "{{pdf}}"

Inside postman the VALUE field has {{pdf}} in white, written inside the usualy file-name box deletable with x.

Any solution appreciated.

Oliver-Java avatar Sep 10 '20 13:09 Oliver-Java