chai-http / superagent:设置mulipart表单字段的Content-Type

时间:2017-09-28 00:39:55

标签: javascript node.js chai superagent chai-http

在集成测试中上传文件,如下所示:

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()
            })

多部分文件的内容类型为:application/octet-stream,我需要它为image/png。我该怎么设置呢?

0 个答案:

没有答案