chai-http/superagent : set Content-Type of mulipart form field

大憨熊 提交于 2020-02-04 03:50:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!