Alejandro Sanchez
06/09/2020, 5:35 AMCannot destructure property 'createReadStream' of 'file' as it is undefined.
Alejandro Sanchez
06/09/2020, 5:35 AMServer is running on <http://localhost:4000>
{
name: Promise {
{
filename: 'bio_alejandro.png',
mimetype: 'image/png',
encoding: '7bit',
createReadStream: [Function: createReadStream]
}
}
}
TypeError: Cannot destructure property 'createReadStream' of 'file' as it is undefined.
at singleUpload (/Users/sancheza/Library/Mobile Documents/com~apple~CloudDocs/Projects/homeinroom/server/src/resolvers/Mutation.js:29:12)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Alejandro Sanchez
06/09/2020, 5:35 AMasync function singleUpload(parent, args, context) {
console.log(args);
const userId = getUserId(context);
const file = await args.file
const {createReadStream, filename, mimetype} = file;
const stream = createReadStream();
stream.pipe(fs.createWriteStream(filename));
return context.prisma.createFile({ name: filename });
}
Alejandro Sanchez
06/09/2020, 5:36 AMAlex Vilchis
06/09/2020, 5:48 AMAlex Vilchis
06/09/2020, 5:49 AMFlorian
06/09/2020, 7:39 AMawait file
^^ -->
const {
createReadStream,
filename,
mimetype,
} = await file;
Alejandro Sanchez
06/09/2020, 3:42 PMAlejandro Sanchez
06/09/2020, 3:43 PM