Getting started
Upload several files in sequence
Example of how to iterate over a file list and call upload() for each one, with the session guaranteed on page load.
1 min read
upload() accepts a single File per call. To send several files — for example, every file chosen in an <input type="file" multiple> — iterate over the list and call upload() for each one. Each file in the batch must also follow the .json.gz format (gzip-compressed JSON Lines).
Example
<script src="https://cdn.infinity6.ai/releases/sdkweb/latest/bundle/i6sdk-web.js"></script>
<input type="file" id="files" multiple="" accept=".gz"/>
<script type="module">
const sdk = window.I6Sdk;
async function main() {
// Guarantee the session before any upload.
const user = await sdk.auth().requireUser();
if (!user) return;
document.querySelector("#files").addEventListener("change", async (event) => {
for (const file of event.target.files) {
try {
await sdk.ingest().upload({
dataset: "<your-dataset>",
table: "<your-table>",
partitions: { "<your-key>": "<your-value>" },
file,
});
console.log(`Uploaded: ${file.name}`);
} catch (error) {
console.error(`Failed on ${file.name}:`, error);
}
}
});
}
main();
</script>Points of attention
- Uploads happen in sequence, one at a time, which makes it easier to identify which file failed and resume from it.
- Each iteration has its own
try/catch, isolating errors per file so a single failure does not interrupt the upload of the remaining files.
Full reference
Support
Implementation support
Official channels for questions during integration.
Technical support email
Response within 1 business day
Send implementation questions with the context of your current step.
Send emailResponse according to the support queue
Direct assistance for quick integration questions.
Support assistant
Immediate response
i6 documentation and implementation assistant.
