Spaces:
Running
Running
File size: 607 Bytes
27e706d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import { Injectable } from "@nestjs/common";
import { v2 as cloudinary } from "cloudinary";
import streamifier from "streamifier";
@Injectable()
export class CloudinaryService {
async uploadImage(file: Express.Multer.File) {
return new Promise<any>((resolve, reject) => {
const stream = cloudinary.uploader.upload_stream(
{
folder: "maternalert/ocr",
},
(error, result) => {
if (error) return reject(error);
resolve(result);
},
);
streamifier
.createReadStream(file.buffer)
.pipe(stream);
});
}
} |