Cannot make tests with post request and file upload
See original GitHub issueHi,
I’d like to make some stress test on my nodejs server with post
requests that send files on the server.
Here is the code I’m testing with:
config:
target: 'https://websi.te'
phases:
- duration: 10
arrivalRate: 10
scenarios:
- flow:
- get:
url: "/"
- post:
url: "/upload/"
formData:
photos: '@./file.jpg'
token: 'myToken'
The error I have on my server is the following:
(node:27684) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 100): TypeError: Cannot read property 'token' of undefined
I have also an error 500
if I remove the token and its requirement from the server.
Note that this NodeJs Request
code is working:
var options = { method: 'POST',
url: 'http://websi.te/upload',
headers:
{ 'postman-token': '4997a0b0-71c8-61cf-c434-2b458dd4320c',
'cache-control': 'no-cache',
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWwktrZu0gW' },
formData:
{ photos:
{ value: 'fs.createReadStream("file.jpg")',
options: { filename: 'file.jpg', contentType: null } },
token: 'myToken' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Thanks for your help.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Unable to send POST request in jmeter which have file upload ...
I am using Parameters for JSON Data and File Upload for file uploading in JMeter. Also used HTTP header manager for content type...
Read more >How to unit test a POST request that has an uploaded file
How to unit test a POST request that has an uploaded file. I'm setting up a route that will take a file upload,...
Read more >Testing file uploads with Postman (multipart/form-data)
I will show you how to debug an upload script and demonstrate it with a tool called Postman that can make requests encoded...
Read more >Postman Tutorial - Upload a file with POST Request - YouTube
In this video we will learn different ways to upload a file with a Post Request in PostmanFound this video interesting - Please...
Read more >POST method uploads - Manual - PHP
Be sure your file upload form has attribute enctype="multipart/form-data" otherwise the file upload will not work. The global $_FILES will contain all the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the same problem and finally made it working. Here’s the example:
Config file:
processor-utils.js
Can you point me to an example please? Thanks.