Table.addFiles
Table.addFiles({ files, directory, maxParallelization, onProgress, signal }) → Promise<void>
Uploads non-tabular files to a file index table (created with isFileIndex: true) in an unreleased version of a dataset. Files are uploaded in parallel, in batches, and large files are uploaded resumably. Exactly one of files or directory must be provided.
// In Node.js, add every file in a directory (named by their path within it)
await table.addFiles({ directory: './images' });
// Add specific files
await table.addFiles({
files: [
'./path/to/file.png', // A file path (Node.js only)
{ path: './path/to/other.png', name: 'renamed.png' }, // A file path, with a different name
{ name: 'hello_world.txt', data: 'Hello world' }, // string, Blob, ArrayBuffer, or typed array data
fileInput.files[0], // A File, e.g., from an <input type="file">
],
});
// In the browser, add every file in a directory picked by the user, keeping its structure
// (with <input type="file" webkitdirectory>)
await table.addFiles({ files: directoryInput.files });Parameters:
files : Array | FileList, optional
The files to add. Each may be a file path (Node.js only); a File, which is named by its path within a picked directory, if any; { path, name? }; or { name, data }, where data is a string (uploaded as UTF-8 text), Blob, ArrayBuffer, or typed array.
directory : string, optional
A local directory whose files are all added, named by their path within it (Node.js only). Hidden files are skipped.
maxParallelization : number, optional
The number of files to upload at once.
onProgress : function, optional
Called with { bytesUploaded, totalBytes, filesUploaded, totalFiles } as the upload progresses.
signal : AbortSignal, optional
Returns: Promise<void>
Was this helpful?

