here I want to use the latest asynchronous way of es6 to achieve, ask for your advice! As I wrote below, I can upload pictures, but I just can"t return the body data. So the result is that the picture has actually been uploaded, but the interface shows 404.
exports.uploadFile = async (ctx,next) => {
let client = new OSS({
region: "oss-cn-qingdao",
accessKeyId: "124214124",
accessKeySecret: "1412414124",
bucket: "p-144-141244"
})
let form = new formidable.IncomingForm()
form.parse(ctx.req, function (err, fields, files) {
client.put(fields.path, files.file.path).then(function (val) {
// console.log(val.res)
ctx.body = {
res: val.res.requestUrls
}
}).then(function (val) {
// console.log(val.res)
// console.log(val.content.toString())
ctx.body = {
res: ""
}
})
})
}