Closed kamalkech closed 3 years ago
Closing because this is a usage question; bug reports and feature suggestions are appropriate for GitHub issues.
Also, there are existing similar issues:
https://github.com/jaydenseric/graphql-upload/issues/204#issuecomment-631153444
Anyone else who has done something similar before feel free to share an answer here though.
Note that there is a maxFileSize
option, if you are happy for all file uploads to share the same limit:
https://github.com/jaydenseric/graphql-upload#type-processrequestoptions
Understood, but maxFileSize
it s for globaly param of application, however we need to check max file size for each type of madia : photos, videos
that ofc has not the same max file size!
I know, I read your issue and the others. Nothing about the graphql-upload
API design is blocking you, go ahead! It's just Node.js streams. Please appreciate that I can't help everyone write their resolvers; there are infinite ways people might want to handle the file upload streams in the backend according to their particular requirements. If I had a code example handy of exactly what you're trying to do I would share it, but I don't.
If you would like to champion a particular approach once you figure it out to help others, feel free to PR the examples. Be conscious that because I don't want to be responsible for an incorrect example, I might take a long time to review it and might decide the effort is not worth it if the example is only useful for a small audience.
Take easy man!, we ask to make sure if this issue from or not graphql-upload
, and for example in @nestjs/commun
we can use a decorator @UploadedFile() file
and we access easly to size like code bellow :
@Post('avatar')
@UseGuards(JwtAuthenticationGuard)
@UseInterceptors(FileInterceptor('file'))
async addAvatar(@UploadedFile() file: any) {
const { createReadStream, filename, mimetype } = await file;
const _buffer = file.buffer;
console.log('byteLength', _buffer.byteLength);
console.log('mimetype', mimetype);
return false;
}
any way, be cool and take easy again, may be we can fixe this issue on the futur, thank you for your words + time ;) !
add file service not runing there another way to get file size ?? Thank you for help