Get registered custom headers for uploads
Get the upload destination path relative to the root folder
Set the upload destination path relative to the root folder
Get the upload queue stats
Get the root folder
Uploads multiple files or folders while preserving the relative path (if available)
The destination path relative to the root folder. e.g. /foo/bar (a file "a.txt" will be uploaded then to "/foo/bar/a.txt")
The files and/or folders to upload
Optional
callback: ((nodes: (File | IDirectory)[], currentPath: string) => Promise<false | (File | IDirectory)[]>)Callback that receives the nodes in the current folder and the current path to allow resolving conflicts, all nodes that are returned will be uploaded (if a folder does not exist it will be created)
Cancelable promise that resolves to an array of uploads
// For example this is from handling the onchange event of an input[type=file]
async handleFiles(files: File[]) {
this.uploads = await this.uploader.batchUpload('uploads', files, this.handleConflicts)
}
async handleConflicts(nodes: File[], currentPath: string) {
const conflicts = getConflicts(nodes, this.fetchContent(currentPath))
if (conflicts.length === 0) {
// No conflicts so upload all
return nodes
} else {
// Open the conflict picker to resolve conflicts
try {
const { selected, renamed } = await openConflictPicker(currentPath, conflicts, this.fetchContent(currentPath), { recursive: true })
return [...selected, ...renamed]
} catch (e) {
return false
}
}
}
Upload a file to the given path
the destination path relative to the root folder. e.g. /foo/bar.txt
the file to upload
Optional
root: stringthe root folder to upload to
number of retries
Initialize uploader