Spaces:
Sleeping
Sleeping
Download src/lib/uploadToHuggingFace.ts from ChrisJohnson111/test100: direct link, hf CLI and curl.
- Browser
- Download file 379 Bytes
-
https://huggingface.co/spaces/ChrisJohnson111/test100/resolve/main/src/lib/uploadToHuggingFace.ts
- Command line
-
hf download hf://spaces/ChrisJohnson111/test100/src/lib/uploadToHuggingFace.ts
-
curl -L -o uploadToHuggingFace.ts https://huggingface.co/spaces/ChrisJohnson111/test100/resolve/main/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 | |
| } |