Hello,
We are using K6 for performance testing. In the pipeline we are pulling latest docker image. We need to call a http.post request and we need to pass a multipart data with a pdf file as input. Following is the code we are using:
const binFile = open(‘test.pdf’, ‘application/octet-stream’);
const fd = new FormData();
var params = {
headers: {
'content-type': undefined, // 'multipart/form-data; boundary=----WebKitFormBoundaryOo98grEHpbmFeVXs',
'Authorization': 'Bearer '+ token()
},
tags: {
name: "Upload Document"
}
};
fd.append(‘content’, http.file(binFile), ‘test.pdf’, ‘application/octet-stream’));
console.log("filename: " + fd.filename); // This is coming undefined
console.log("contenttype: " + fd.content_type); // This is coming undefined
const res = http.post(url, data, params);
Here filename in the formdata is undefined and so this file is not being passed with the request.
Can you please guide what we are doing wrong here?
Thanks & Regards,
Madhura