Spaces:
Running
Running
<input type="file" id="fileInput" multiple> | |
<button onClick="upload()">Upload</button> | |
<script> | |
// Assumes that the `uploadFiles`, `repo`, and `credentials` are available in this scope | |
async function upload() { | |
const input = document.getElementById('fileInput'); | |
const files = Array.from(input.files); // Convert FileList to an Array | |
// Prompt the user for a unique upload path for each file | |
const filesToUpload = await Promise.all(files.map(async (file) => { | |
const path = prompt(`Enter the upload path for ${file.name}`); | |
return { | |
path, | |
content: file, | |
}; | |
})); | |
await uploadFiles({ | |
repo, | |
credentials, | |
files: filesToUpload, | |
}); | |
} | |
</script> | |