frappe-js-sdk
Version:
TypeScript/JavaScript client for Frappe Framework REST API
26 lines (25 loc) • 1.26 kB
TypeScript
import { AxiosInstance, AxiosProgressEvent } from 'axios';
import { FileArgs } from './types';
export declare class FrappeFileUpload {
/** URL of the Frappe App instance */
private readonly appURL;
/** Axios instance */
readonly axios: AxiosInstance;
/** Whether to use the token based auth */
readonly useToken: boolean;
/** Token to be used for authentication */
readonly token?: () => string;
/** Type of token to be used for authentication */
readonly tokenType?: 'Bearer' | 'token';
/** Custom Headers to be passed in request */
readonly customHeaders?: object;
constructor(appURL: string, axios: AxiosInstance, useToken?: boolean, token?: () => string, tokenType?: 'Bearer' | 'token', customHeaders?: object);
/**
* Upload file to database
* @param {File} file to be uploaded
* @param {@type FileArgs} args arguments of the file
* @param {VoidFunction} onProgress file upload progress
* @returns Promise which resolves with the file object
*/
uploadFile<T = any>(file: File, args: FileArgs<T>, onProgress?: (bytesUploaded: number, totalBytes?: number, progress?: AxiosProgressEvent) => void, apiPath?: string): Promise<import("axios").AxiosResponse<any, any, {}>>;
}