问题
Uploading a file in an integration test as follows:
chai.request(server.instance)
.post('/profile/photo/0')
.set('Access-Token', accessToken)
.set('API-Key', testConfig.apiKey)
.set('Content-Type', 'image/png')
.field({contentId: 'foobar'})
.attach('file', fs.readFileSync(__dirname + '/file.png'), 'file')
.end((err, res) => {
console.log(JSON.stringify(res.body))
res.should.have.status(200)
done()
})
The content type of the multipart file is: application/octet-stream
and I need it to be image/png
. How can I set that?
来源:https://stackoverflow.com/questions/46459194/chai-http-superagent-set-content-type-of-mulipart-form-field