postmanlabs / postman-app-support

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
https://www.postman.com
5.84k stars 839 forks source link

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

Open josslamberti opened 7 years ago

josslamberti commented 7 years ago

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).

sdnts commented 7 years ago

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

karthiksml commented 5 years ago

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

vkaegis commented 5 years ago

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

DustinHendrickson commented 5 years ago

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

barcooverture commented 5 years ago

We would love that too !

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

levyblue commented 4 years ago

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

schmitzdenis commented 4 years ago

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.

Chekkov commented 4 years ago

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

schmitzdenis commented 4 years ago

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 ..

Oliver-Java commented 4 years ago

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.