file upload with multipart/form-data via K6 gives TypeError: Cannot read property 'filename' of undefined

291 Views Asked by At

Trying to upload pdf files as form-data, via k6 but getting error.

Code snippet :

let fd = new FormData();
        fd.append('file',http.file(file, 'small_pdf_300kb.pdf', 'application/pdf'));
        fd.append('metadata',JSON.stringify(this.metadata));
        
        let res = http.post(ENDPOINTS.uploadDocument, fd.body(), {
            headers: {
                "Content-Type": 'multipart/form-data; boundary=' + fd.boundary,
                "Authorization": user.token
            }});

Error :

ERRO[0005] TypeError: Cannot read property 'filename' of undefined
running at https://jslib.k6.io/formdata/0.0.2/index.js:81:16(43)
0

There are 0 best solutions below