Skip to content

Instantly share code, notes, and snippets.

@colbyfayock
Created September 25, 2022 20:52
Show Gist options
  • Save colbyfayock/f0778baf2684d49fdaace5ee37e70138 to your computer and use it in GitHub Desktop.
Save colbyfayock/f0778baf2684d49fdaace5ee37e70138 to your computer and use it in GitHub Desktop.
Upload Blob to Cloudinary in Node
const response = await fetch("https://pbs.twimg.com/profile_images/1457798886710738944/HWg9ES8r_400x400.jpg")
const contentType = response.headers.get("Content-Type");
const blob = await response.blob();
const arrayBuffer = await blob.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);
const dataUri = `data:${contentType};base64,${buffer.toString('base64')}`;
const upload = await cloudinary.uploader.upload(dataUri);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment