Not able to uplod file on cloudinary.

How can i upload files to Cloudinary in the Hono app? Everything is sorted but i am not able to get the path of the file as the Cloudinarys uploader function asks for the file path. This is the utils file of Cloudinary import {v2 as cloudinary} from "Cloudinary" import fs from "fs" cloudinary.config({ cloud_name: process.env.CLOUDINARY_CLOUD_NAME, api_key: process.env.CLOUDINARY_API_KEY, api_secret: process.env.CLOUDINARY_API_SECRET }); const uploadOnCloudinary = async (localFilePath) => { try { if (!localFilePath) return null //upload the file onCloudinaryy const response = await cloudinary.uploader.upload(localFilePath, { resource_type: "auto" }) // file has been uploadedsuccessfull //console.log("file is uploaded onCloudinaryy ", response.url); fs.unlinkSync(localFilePath) return response; } catch (error) { fs.unlinkSync(localFilePath) // remove the locally saved temporary file as the upload operation got failed return null; } } export {uploadOnCloudinary} PROBLEM: // i get the file but not able to get the path // code const body = await ctx.req.parseBody() console.log(body["image"]); // output image: File { lastModified: 1712061871701, name: 'm5.jpg', type: 'image/jpeg', size: 84673 } my refrense : https://hono.dev/api/request#parsebody
HonoRequest - Hono
Ultrafast web framework for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
S
Sam13d ago
Doesn't seem like you're using a Cloudflare product in this code, right?