Files
Resource for operations related to files.
Class: Files
Resource for operations related to files.
Constructors
Constructor
new Files(
fetchImpl,headers,uploads):Files
Create a new Files resource.
Parameters
fetchImpl
{(input, init?): Promise<Response>; (input, init?): Promise<Response>; }
Fetch implementation to use.
headers
Record<string, string>
Additional headers to send with file upload requests.
uploads
An instance of the uploads resource.
Returns
Files
Methods
upload()
upload(
file,signal?):Promise<UploadCompletionResult>
Upload a file.
The upload is streamed, but the underlying data may already be
in memory depending on how file was constructed.
For example, a browser File from an <input> or Node's
openAsBlob() stream from disk, while new Blob([buffer]) or
Uint8Array require the data to already be in memory.
Large files are split into parts by the server and uploaded concurrently.
Parameters
file
The file to upload.
signal?
AbortSignal
Optional AbortSignal to cancel the request.
Returns
Promise<UploadCompletionResult>
Result of the completed upload.