我正在尝试通过以下突变通知on('finished')
处的前端。我看过一些相当冗长的教程like this,以了解如何做,但似乎远远超出了我的需要。
我只想能够在图像上传完成后在React中更改状态。我正在使用Recoil,因此在我的情况下,它将设置一个uploadingState
原子。
Mutation: {
uploadFile: async (_, { file }) => {
const { createReadStream, filename } = await file;
await new Promise(res =>
createReadStream()
.pipe(
wudditBucket.file(filename).createWriteStream({
resumable: false,
gzip: true,
}),
)
.on('finish', res), // setRecoil atom when this is fires?
);
files.push(filename);
return true;
},
},