forwardemail / forwardemail/supertest
Unsupported Media Type: multipart/form-data;
- Dominant language
- JavaScript
- Stars
- 14.4k
- Forks
- 782
- PR merge metrics
- No merged PRs in 30d
Description
Trying to send file via attach method is not working..
```
await request(app.getHttpServer())
.post('/uploads/avatar')
.set('Content-type', 'application/octet-stream')
.auth(userToken.accessToken, { type: 'bearer' })
.attach('file', buffer, 'test.jpg')
.expect(({ status, body }) => {
console.log(body);
expect(status).toBe(400);
});
```
Have tried withou set content type, passing options on attach method and i'm gettin same error always.
This is the console.log of all request
```Test {
_events: [Object: null prototype] {
end: [Function: bound onceWrapper] {
listener: [Function: bound _clearTimeout]
}
},
_eventsCount: 1,
_maxListeners: undefined,
_agent: false,
_formData: FormData {
_overheadLength: 150,
_valueLength: 37351,
_valuesToMeasure: [],
writable: false,
readable: true,
dataSize: 0,
maxDataSize: 2097152,
pauseStreams: true,
_released: false,
_streams: [
'----------------------------705062276704130245747665\r\n' +
'Content-Disposition: form-data; name="file"; filename="test.jpg"\r\n' +
'Content-Type: image/jpeg\r\n' +
'\r\n',
,
[Function: bound ]
],
_currentStream: null,
_insideLoop: false,
_pendingNext: false,
_events: [Object: null prototype] { error: [Function] },
_eventsCount: 1,
_boundary: '--------------------------705062276704130245747665'
},
method: 'POST',
url: 'http://127.0.0.1:41895/uploads/avatar',
_header: {
'user-agent': 'node-superagent/3.8.3',
authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAY29sbGFtYXAub3JnIiwiZmlyc3RuYW1lIjoiVXNlciIsImxhc3RuYW1lIjoiVXNlciIsImF2YXRhciI6IiIsImlhdCI6MTYxNDEwMjk2OSwiZXhwIjoxNjE0MTAzMjY5fQ.YRud3pAACN51HDRleuc1lYd4-yuyrlANY9kmwSpA1O0'
},
header: {
'User-Agent': 'node-superagent/3.8.3',
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAY29sbGFtYXAub3JnIiwiZmlyc3RuYW1lIjoiVXNlciIsImxhc3RuYW1lIjoiVXNlciIsImF2YXRhciI6IiIsImlhdCI6MTYxNDEwMjk2OSwiZXhwIjoxNjE0MTAzMjY5fQ.YRud3pAACN51HDRleuc1lYd4-yuyrlANY9kmwSpA1O0'
},
writable: true,
_redirects: 0,
_maxRedirects: 0,
cookies: '',
qs: {},
_query: [],
qsRaw: [],
_redirectList: [],
_streamRequest: false,
_buffer: true,
app: Server {
_events: [Object: null prototype] {
request: [Function: bound lookup],
connection: [Function: connectionListener],
clientError: [Function: bound defaultClientErrorHandler]
},
_eventsCount: 3,
_maxListeners: undefined,
_connections: 0,
_handle: TCP {
reading: false,
onconnection: [Function: onconnection],
[Symbol(owner)]: [Circular]
},
_usingWorkers: false,
_workers: [],
_unref: false,
allowHalfOpen: true,
pauseOnConnect: false,
httpAllowHalfOpen: false,
timeout: 0,
keepAliveTimeout: 5000,
maxHeadersCount: null,
headersTimeout: 40000,
_connectionKey: '6::::0',
[Symbol(IncomingMessage)]: [Function: IncomingMessage],
[Symbol(ServerResponse)]: [Function: ServerResponse],
[Symbol(asyncId)]: 916
},
_asserts: [],
_server: Server {
_events: [Object: null prototype] {
request: [Function: bound lookup],
connection: [Function: connectionListener],
clientError: [Function: bound defaultClientErrorHandler]
},
_eventsCount: 3,
_maxListeners: undefined,
_connections: 0,
_handle: TCP {
reading: false,
onconnection: [Function: onconnection],
[Symbol(owner)]: [Circular]
},
_usingWorkers: false,
_workers: [],
_unref: false,
allowHalfOpen: true,
pauseOnConnect: false,
httpAllowHalfOpen: false,
timeout: 0,
keepAliveTimeout: 5000,
maxHeadersCount: null,
headersTimeout: 40000,
_connectionKey: '6::::0',
[Symbol(IncomingMessage)]: [Function: IncomingMessage],
[Symbol(ServerResponse)]: [Function: ServerResponse],
[Symbol(asyncId)]: 916
}
}
```
Contributor guide
Research direction
Reproduce the multipart upload using the shown POST request, attach call, and Content-Type settings. Start by tracing the request-building path used by attach and compare the generated multipart headers with the server response. Done means the documented upload request no longer receives the reported Unsupported Media Type response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100