Created
May 9, 2024 11:05
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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