-
Notifications
You must be signed in to change notification settings - Fork 50
Support file upload #45
Support file upload #45
Conversation
Here's a collection that uploads the httpbin and displays the result. {
"info": {
"_postman_id": "de6446a1-6b5f-4006-b438-1fe70466daf8",
"name": "File Upload",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "TestFileUpload",
"event": [
{
"listen": "test",
"script": {
"id": "e41d8c08-1399-4956-a5f9-175f90e6eade",
"exec": [
"console.log(pm.response.text());",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"type": "file",
"src": "theultimatequestion.txt"
}
]
},
"url": {
"raw": "http://httpbin.org/post",
"protocol": "http",
"host": [
"httpbin",
"org"
],
"path": [
"post"
]
}
},
"response": []
}
],
"protocolProfileBehavior": {}
} It looks for a file
|
@marcelo-dalmeida I wonder if you'd be willing to test this with your collection? It would help to confirm it does the right thing with real input. You can do it like this. git clone https://github.com/bookmoons/postman-to-k6.git
cd postman-to-k6
git branch bookmoons/file-upload
node bin/postman-to-k6.js collection.json |
I'm doing it now |
Feel free to ask me to test it anytime you need Here a snippet from my attempt: |
Whoops, my fault. Got to have an
|
Really need to test my instructions before posting. Branch was the wrong command. Checkout is the right thing. This gets it to the right code for me. git checkout master
git branch -D bookmoons/file-upload
git checkout bookmoons/file-upload
npm install
node bin/postman-to-k6.js collection.json |
Hi @bookmoons Sorry, I could have noted it too. For the problem at matter That's the generated file: I now find the original error (as you noted in the issue, it was two different errors): So I think it may be better to create another issue and associate this pull request to that Also, thank you for working on it |
OK, thanks a lot for testing. It's a good bug. I included a fix for this but clearly it didn't quite do it. Will investigate. |
Is it possible you were executing the old conversion here? The conversion seems to work for me. Here's a tested script that pulls and converts. It doesn't find the upload file on my system but it should be there on yours. #!/bin/bash
git clone https://github.com/bookmoons/postman-to-k6.git
cd postman-to-k6
git checkout bookmoons/file-upload
npm install
wget https://github.com/loadimpact/postman-to-k6/files/3745258/recommendation.postman_collection.zip
unzip recommendation.postman_collection.zip
rm recommendation.postman_collection.zip
node bin/postman-to-k6.js recommendation.postman_collection.json >upload.js
k6 run upload.js I think it will also find a missing environment. In Postman you can export the environment, then the converter can take it on the command line.
Also pushed a fix for paths, Postman seems to encode a Windows path a little differently. |
Hi @bookmoons
Recapitulating my actions: Well, I cleaned as you instructed:
Then I saw file info that was not present before in the script. So I tested with run as the conversion seemed fine to me. I also sent you the file so you could double-check what I was running
It seemed 'double-fine' to me as it was giving me the very same error I found when I manually fixed the file part of the script. It was then a matter about the file being binary. Now I ran the conversion again (from the scratch) and included the missing environment. |
B-Finder Copy.postman_environment.zip I'm sending you a copy, but I just removed 'sensitive' information |
Appreciate the report and testing @marcelo-dalmeida. Pointing your collection at httpbin successfully uploads for me, so I think it's in good shape. After review / possible bug fixes this should land in the next release. Your collection has a header |
I think this is ready for review. |
For consistency with Postman behavior.
Pardon delay in reviewing. LGTM. Merging. |
Adds support for the file upload feature of Postman collections.
Postman usage is in the request body interface with a type
form-body
. Each entry can be converted to a file and have a path specified. Hovering reveals the control.Postman seems to always use absolute paths. The conversion preserves paths and leaves the files where they are.
Closes #42.