前端
let formData = new FormData();
formData.append('type', type);
formData.append('file', file);
const res = await upload(formData);
egg
const file = this.ctx.request.files[0];
const result = await ctx.oss.put(`${new Date().getTime()}`, filepath, {
headers: {
'Content-Type': 'image/jpg',
}
});
注: 添加header信息返回的链接是预览,不加返回链接打开直接下载
egg-oss api查看
https://github.com/ali-sdk/ali-oss
网友评论