SkillHub

Connect

Discover

My Work

Activity











Product

  • About
  • Team
  • Careers

Support

  • How it works
  • Trust & Safety
  • Help Centre

Discover

  • Guides
  • Stories
  • News

Browse

  • Freelance Services
  • Freelance Skills
  • Partnerships

© SkillHub Connect Ltd. 2025

a new file upload

Updated 1 year ago

Shahbaz Ansari
Service Image

Catalog Details

import { v2 as cloudinary } from 'cloudinary'; cloudinary.config({ cloud_name: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME, api_key: process.env.CLOUDINARY_API_KEY, api_secret: process.env.CLOUDINARY_API_SECRET, secure: true, }); export const uploadImageToCloudinary = async ( buffer: Buffer, path: string, onProgress: (percentage: number) => void ): Promise<any> => { return new Promise((resolve, reject) => { const url = `https://api.cloudinary.com/v1_1/${cloudinary.config().cloud_name}/upload`; const xhr = new XMLHttpRequest(); xhr.open('POST', url, true); xhr.upload.onprogress = (event) => { if (event.lengthComputable) { const percentComplete = (event.loaded / event.total) * 100; onProgress(percentComplete); } }; xhr.onload = () => { if (xhr.status >= 200 && xhr.status < 300) { resolve(JSON.parse(xhr.responseText)); } else { reject(new Error(xhr.statusText)); } }; xhr.onerror = () => reject(new Error('Upload failed'));

Skills and Expertise

websiteuiproductivity

$234

Delivery Time

2 days

Number of Revisions

3