I want to upload a file using cloudinary but it's not working. What it the file string parameter should be?
@Injectable()
export class CloudinaryService {
async uploadImage(
file: Express.Multer.File,
id: string,
): Promise<UploadApiResponse | UploadApiErrorResponse> {
return new Promise((resolve, reject) => {
v2.uploader.upload(
file.filename,
{ public_id: id, folder: 'business', resource_type: 'auto' },
(error, result) => {
if (error) return reject(error);
resolve(result);
},
);
});
}
}
Here's the file object
{
fieldname: 'DirectorsDetails',
originalname: 'Eddy - Information about directors.xlsx',
encoding: '7bit',
mimetype: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
buffer: <Buffer 50 4b 03 04 14 00 08 08 08 00 14 2a be 52 00 00 00 00 00 00 00 00 00 00 00 00 18 00 00 00 78 6c 2f 64 72 61 77 69 6e 67 73 2f 64 72 61 77 69 6e 67 31 ... 5072 more bytes>,
size: 5122
}