Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save samyarkd/a490d50c74e7f353650e54fca479a430 to your computer and use it in GitHub Desktop.
Save samyarkd/a490d50c74e7f353650e54fca479a430 to your computer and use it in GitHub Desktop.
Run this code with Bun it will throw an error but with node it will work without any issues
import { UTApi } from "uploadthing/server";
export const utapi = new UTApi();
/**
* Uploads an image from the given URL.
*
* @param {string} url - The URL of the image to be uploaded
* @return {Promise<any>} A Promise that resolves with the result of the upload process
*/
async function uploadImageByUrl(url: string) {
return await utapi.uploadFilesFromUrl(url);
}
uploadImageByUrl(
"https://th.bing.com/th/id/OIP.ylJG0kH7UjV6aBXIJWajfgHaDt?rs=1&pid=ImgDetMain",
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment