'How to upload files through nestjs websocket?
Below I try to get the file through the fileInterceptor interceptor, but the upload is not being performed.
@SubscribeMessage('user:setAvatar')
@UseInterceptors(FileInterceptor('userAvatar', {
storage: diskStorage({
destination: function(req, file, cb) {
console.log(file);
cb(null, 'uploads/');
},
filename: function(req, file, cb) {
cb(null, file.fieldname + '-' + Date.now());
}
})
}))
async setAvatar(client: any, @UploadedFile() file: any): Promise<void> {
console.log(file);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
