Skip to content

@sqlrooms/utils / uploadFile

Function: uploadFile()

uploadFile(url, content, opts?): Promise<Response>

Uploads a file to a specified URL using XMLHttpRequest

Parameters

ParameterTypeDescription
urlstringThe URL to upload the file to
contentFile | Blob | FormDataThe content to upload
opts?{ method: string; headers: Record<string, string>; onProgress: (info) => void; }Optional configuration for the upload
opts.method?stringThe HTTP method to use
opts.headers?Record<string, string>Additional headers to include in the request
opts.onProgress?(info) => voidCallback function to track upload progress

Returns

Promise<Response>

The server response

Throws

Throws an object containing status and error message if upload fails