Download src/lib/uploadToHuggingFace.ts from aigorithm/aicartoons: direct link, hf CLI and curl.
- Browser
- Download file 379 Bytes
-
https://huggingface.co/aigorithm/aicartoons/resolve/refs%2Fpr%2F1/src/lib/uploadToHuggingFace.ts
- Command line
-
hf download hf://aigorithm/aicartoons@refs/pr/1/src/lib/uploadToHuggingFace.ts
-
curl -L -o uploadToHuggingFace.ts https://huggingface.co/aigorithm/aicartoons/resolve/refs%2Fpr%2F1/src/lib/uploadToHuggingFace.ts
379 Bytes
| export async function uploadToHuggingFace(file: File) { | |
| const UPLOAD_URL = 'https://huggingface.co/uploads' | |
| const response = await fetch(UPLOAD_URL, { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': file.type, | |
| 'X-Requested-With': 'XMLHttpRequest', | |
| }, | |
| body: file, /// <- File inherits from Blob | |
| }) | |
| const url = await response.text() | |
| return url | |
| } |