16b7802baSBartosz Kaszubowski/** 26b7802baSBartosz Kaszubowski * These values can be used to define how sessions work on iOS. 36b7802baSBartosz Kaszubowski * @platform ios 46b7802baSBartosz Kaszubowski */ 5da65a760SŁukasz Kosmatyexport enum FileSystemSessionType { 66b7802baSBartosz Kaszubowski /** 7da65a760SŁukasz Kosmaty * Using this mode means that the downloading/uploading session on the native side will work even if the application is moved to background. 8da65a760SŁukasz Kosmaty * If the task completes while the application is in background, the Promise will be either resolved immediately or (if the application execution has already been stopped) once the app is moved to foreground again. 96b7802baSBartosz Kaszubowski * > Note: The background session doesn't fail if the server or your connection is down. Rather, it continues retrying until the task succeeds or is canceled manually. 10da65a760SŁukasz Kosmaty */ 11da65a760SŁukasz Kosmaty BACKGROUND = 0, 126b7802baSBartosz Kaszubowski /** 13da65a760SŁukasz Kosmaty * Using this mode means that downloading/uploading session on the native side will be terminated once the application becomes inactive (e.g. when it goes to background). 14da65a760SŁukasz Kosmaty * Bringing the application to foreground again would trigger Promise rejection. 15da65a760SŁukasz Kosmaty */ 16da65a760SŁukasz Kosmaty FOREGROUND = 1, 17da65a760SŁukasz Kosmaty} 18da65a760SŁukasz Kosmaty 1937630a92SŁukasz Kosmatyexport enum FileSystemUploadType { 206b7802baSBartosz Kaszubowski /** 216b7802baSBartosz Kaszubowski * The file will be sent as a request's body. The request can't contain additional data. 226b7802baSBartosz Kaszubowski */ 2337630a92SŁukasz Kosmaty BINARY_CONTENT = 0, 246b7802baSBartosz Kaszubowski /** 256b7802baSBartosz Kaszubowski * An [RFC 2387-compliant](https://www.ietf.org/rfc/rfc2387.txt) request body. The provided file will be encoded into HTTP request. 266b7802baSBartosz Kaszubowski * This request can contain additional data represented by [`UploadOptionsMultipart`](#uploadoptionsmultipart) type. 276b7802baSBartosz Kaszubowski */ 2837630a92SŁukasz Kosmaty MULTIPART = 1, 2937630a92SŁukasz Kosmaty} 3037630a92SŁukasz Kosmaty 312307aaceSEvan Baconexport type DownloadOptions = { 326b7802baSBartosz Kaszubowski /** 336b7802baSBartosz Kaszubowski * If `true`, include the MD5 hash of the file in the returned object. Provided for convenience since it is common to check the integrity of a file immediately after downloading. 346b7802baSBartosz Kaszubowski * @default false 356b7802baSBartosz Kaszubowski */ 362307aaceSEvan Bacon md5?: boolean; 376b7802baSBartosz Kaszubowski // @docsMissing 3877c88547SEvan Bacon cache?: boolean; 396b7802baSBartosz Kaszubowski /** 406b7802baSBartosz Kaszubowski * An object containing all the HTTP header fields and their values for the download network request. The keys and values of the object are the header names and values respectively. 416b7802baSBartosz Kaszubowski */ 42da65a760SŁukasz Kosmaty headers?: Record<string, string>; 436b7802baSBartosz Kaszubowski /** 446b7802baSBartosz Kaszubowski * A session type. Determines if tasks can be handled in the background. On Android, sessions always work in the background and you can't change it. 456b7802baSBartosz Kaszubowski * @default FileSystemSessionType.BACKGROUND 466b7802baSBartosz Kaszubowski * @platform ios 47da65a760SŁukasz Kosmaty */ 48da65a760SŁukasz Kosmaty sessionType?: FileSystemSessionType; 492307aaceSEvan Bacon}; 502307aaceSEvan Bacon 51da65a760SŁukasz Kosmatyexport type FileSystemHttpResult = { 526b7802baSBartosz Kaszubowski /** 536b7802baSBartosz Kaszubowski * An object containing all the HTTP response header fields and their values for the download network request. 546b7802baSBartosz Kaszubowski * The keys and values of the object are the header names and values respectively. 556b7802baSBartosz Kaszubowski */ 56da65a760SŁukasz Kosmaty headers: Record<string, string>; 576b7802baSBartosz Kaszubowski /** 586b7802baSBartosz Kaszubowski * The HTTP response status code for the download network request. 596b7802baSBartosz Kaszubowski */ 602307aaceSEvan Bacon status: number; 616b7802baSBartosz Kaszubowski // @docsMissing 62da65a760SŁukasz Kosmaty mimeType: string | null; 63da65a760SŁukasz Kosmaty}; 64da65a760SŁukasz Kosmaty 65da65a760SŁukasz Kosmatyexport type FileSystemDownloadResult = FileSystemHttpResult & { 666b7802baSBartosz Kaszubowski /** 676b7802baSBartosz Kaszubowski * A `file://` URI pointing to the file. This is the same as the `fileUri` input parameter. 686b7802baSBartosz Kaszubowski */ 69da65a760SŁukasz Kosmaty uri: string; 706b7802baSBartosz Kaszubowski /** 716b7802baSBartosz Kaszubowski * Present if the `md5` option was truthy. Contains the MD5 hash of the file. 726b7802baSBartosz Kaszubowski */ 732307aaceSEvan Bacon md5?: string; 742307aaceSEvan Bacon}; 752307aaceSEvan Bacon 76da65a760SŁukasz Kosmaty/** 7765428d51SBartłomiej Klocek * @deprecated Use `FileSystemDownloadResult` instead. 78da65a760SŁukasz Kosmaty */ 79da65a760SŁukasz Kosmatyexport type DownloadResult = FileSystemDownloadResult; 80da65a760SŁukasz Kosmaty 816b7802baSBartosz Kaszubowskiexport type FileSystemUploadOptions = (UploadOptionsBinary | UploadOptionsMultipart) & { 826b7802baSBartosz Kaszubowski /** 836b7802baSBartosz Kaszubowski * An object containing all the HTTP header fields and their values for the upload network request. 846b7802baSBartosz Kaszubowski * The keys and values of the object are the header names and values respectively. 856b7802baSBartosz Kaszubowski */ 86da65a760SŁukasz Kosmaty headers?: Record<string, string>; 876b7802baSBartosz Kaszubowski /** 886b7802baSBartosz Kaszubowski * The request method. 896b7802baSBartosz Kaszubowski * @default FileSystemAcceptedUploadHttpMethod.POST 906b7802baSBartosz Kaszubowski */ 91da65a760SŁukasz Kosmaty httpMethod?: FileSystemAcceptedUploadHttpMethod; 926b7802baSBartosz Kaszubowski /** 936b7802baSBartosz Kaszubowski * A session type. Determines if tasks can be handled in the background. On Android, sessions always work in the background and you can't change it. 946b7802baSBartosz Kaszubowski * @default FileSystemSessionType.BACKGROUND 956b7802baSBartosz Kaszubowski * @platform ios 966b7802baSBartosz Kaszubowski */ 97da65a760SŁukasz Kosmaty sessionType?: FileSystemSessionType; 98da65a760SŁukasz Kosmaty}; 99da65a760SŁukasz Kosmaty 1006b7802baSBartosz Kaszubowski/** 1016b7802baSBartosz Kaszubowski * Upload options when upload type is set to binary. 1026b7802baSBartosz Kaszubowski */ 1036b7802baSBartosz Kaszubowskiexport type UploadOptionsBinary = { 1046b7802baSBartosz Kaszubowski /** 1056b7802baSBartosz Kaszubowski * Upload type determines how the file will be sent to the server. 1066b7802baSBartosz Kaszubowski * Value will be `FileSystemUploadType.BINARY_CONTENT`. 1076b7802baSBartosz Kaszubowski */ 1086b7802baSBartosz Kaszubowski uploadType?: FileSystemUploadType; 1096b7802baSBartosz Kaszubowski}; 1106b7802baSBartosz Kaszubowski 1116b7802baSBartosz Kaszubowski/** 1126b7802baSBartosz Kaszubowski * Upload options when upload type is set to multipart. 1136b7802baSBartosz Kaszubowski */ 1146b7802baSBartosz Kaszubowskiexport type UploadOptionsMultipart = { 1156b7802baSBartosz Kaszubowski /** 1166b7802baSBartosz Kaszubowski * Upload type determines how the file will be sent to the server. 1176b7802baSBartosz Kaszubowski * Value will be `FileSystemUploadType.MULTIPART`. 1186b7802baSBartosz Kaszubowski */ 1196b7802baSBartosz Kaszubowski uploadType: FileSystemUploadType; 1206b7802baSBartosz Kaszubowski /** 1216b7802baSBartosz Kaszubowski * The name of the field which will hold uploaded file. Defaults to the file name without an extension. 1226b7802baSBartosz Kaszubowski */ 1236b7802baSBartosz Kaszubowski fieldName?: string; 1246b7802baSBartosz Kaszubowski /** 1256b7802baSBartosz Kaszubowski * The MIME type of the provided file. If not provided, the module will try to guess it based on the extension. 1266b7802baSBartosz Kaszubowski */ 1276b7802baSBartosz Kaszubowski mimeType?: string; 1286b7802baSBartosz Kaszubowski /** 1296b7802baSBartosz Kaszubowski * Additional form properties. They will be located in the request body. 1306b7802baSBartosz Kaszubowski */ 1316b7802baSBartosz Kaszubowski parameters?: Record<string, string>; 1326b7802baSBartosz Kaszubowski}; 1336b7802baSBartosz Kaszubowski 134da65a760SŁukasz Kosmatyexport type FileSystemUploadResult = FileSystemHttpResult & { 1356b7802baSBartosz Kaszubowski /** 1366b7802baSBartosz Kaszubowski * The body of the server response. 1376b7802baSBartosz Kaszubowski */ 138da65a760SŁukasz Kosmaty body: string; 139da65a760SŁukasz Kosmaty}; 140da65a760SŁukasz Kosmaty 1416b7802baSBartosz Kaszubowski// @docsMissing 14252eeb172SŁukasz Kosmatyexport type FileSystemNetworkTaskProgressCallback< 143*8a424bebSJames Ide T extends DownloadProgressData | UploadProgressData, 14452eeb172SŁukasz Kosmaty> = (data: T) => void; 14552eeb172SŁukasz Kosmaty 14652eeb172SŁukasz Kosmaty/** 1476b7802baSBartosz Kaszubowski * @deprecated use `FileSystemNetworkTaskProgressCallback<DownloadProgressData>` instead. 14852eeb172SŁukasz Kosmaty */ 14952eeb172SŁukasz Kosmatyexport type DownloadProgressCallback = FileSystemNetworkTaskProgressCallback<DownloadProgressData>; 1502307aaceSEvan Bacon 1512307aaceSEvan Baconexport type DownloadProgressData = { 1526b7802baSBartosz Kaszubowski /** 1536b7802baSBartosz Kaszubowski * The total bytes written by the download operation. 1546b7802baSBartosz Kaszubowski */ 1552307aaceSEvan Bacon totalBytesWritten: number; 1566b7802baSBartosz Kaszubowski /** 1576b7802baSBartosz Kaszubowski * The total bytes expected to be written by the download operation. A value of `-1` means that the server did not return the `Content-Length` header 1586b7802baSBartosz Kaszubowski * and the total size is unknown. Without this header, you won't be able to track the download progress. 1596b7802baSBartosz Kaszubowski */ 1602307aaceSEvan Bacon totalBytesExpectedToWrite: number; 1612307aaceSEvan Bacon}; 1622307aaceSEvan Bacon 16352eeb172SŁukasz Kosmatyexport type UploadProgressData = { 1646b7802baSBartosz Kaszubowski /** 1656b7802baSBartosz Kaszubowski * The total bytes sent by the upload operation. 1666b7802baSBartosz Kaszubowski */ 1674ee48f97SGabriel Donadel Dall'Agnol totalBytesSent: number; 1684ee48f97SGabriel Donadel Dall'Agnol /** 1696b7802baSBartosz Kaszubowski * The total bytes expected to be sent by the upload operation. 1706b7802baSBartosz Kaszubowski */ 17152eeb172SŁukasz Kosmaty totalBytesExpectedToSend: number; 17252eeb172SŁukasz Kosmaty}; 17352eeb172SŁukasz Kosmaty 1742307aaceSEvan Baconexport type DownloadPauseState = { 1756b7802baSBartosz Kaszubowski /** 1766b7802baSBartosz Kaszubowski * The remote URI to download from. 1776b7802baSBartosz Kaszubowski */ 1782307aaceSEvan Bacon url: string; 1796b7802baSBartosz Kaszubowski /** 1806b7802baSBartosz Kaszubowski * The local URI of the file to download to. If there is no file at this URI, a new one is created. If there is a file at this URI, its contents are replaced. 1816b7802baSBartosz Kaszubowski */ 1822307aaceSEvan Bacon fileUri: string; 1836b7802baSBartosz Kaszubowski /** 1846b7802baSBartosz Kaszubowski * Object representing the file download options. 1856b7802baSBartosz Kaszubowski */ 1862307aaceSEvan Bacon options: DownloadOptions; 1876b7802baSBartosz Kaszubowski /** 1886b7802baSBartosz Kaszubowski * The string which allows the API to resume a paused download. 1896b7802baSBartosz Kaszubowski */ 1902307aaceSEvan Bacon resumeData?: string; 1912307aaceSEvan Bacon}; 1922307aaceSEvan Bacon 1936b7802baSBartosz Kaszubowski/* eslint-disable */ 1942307aaceSEvan Baconexport type FileInfo = 1956b7802baSBartosz Kaszubowski /** 1966b7802baSBartosz Kaszubowski * Object returned when file exist. 1976b7802baSBartosz Kaszubowski */ 1986b7802baSBartosz Kaszubowski { 1996b7802baSBartosz Kaszubowski /** 2006b7802baSBartosz Kaszubowski * Signifies that the requested file exist. 2016b7802baSBartosz Kaszubowski */ 2022307aaceSEvan Bacon exists: true; 2036b7802baSBartosz Kaszubowski /** 2046b7802baSBartosz Kaszubowski * A `file://` URI pointing to the file. This is the same as the `fileUri` input parameter. 2056b7802baSBartosz Kaszubowski */ 2062307aaceSEvan Bacon uri: string; 2076b7802baSBartosz Kaszubowski /** 2086b7802baSBartosz Kaszubowski * The size of the file in bytes. If operating on a source such as an iCloud file, only present if the `size` option was truthy. 2096b7802baSBartosz Kaszubowski */ 2102307aaceSEvan Bacon size: number; 2116b7802baSBartosz Kaszubowski /** 2126b7802baSBartosz Kaszubowski * Boolean set to `true` if this is a directory and `false` if it is a file. 2136b7802baSBartosz Kaszubowski */ 214eed6b87bSStanisław Chmiela isDirectory: boolean; 2156b7802baSBartosz Kaszubowski /** 2166b7802baSBartosz Kaszubowski * The last modification time of the file expressed in seconds since epoch. 2176b7802baSBartosz Kaszubowski */ 2182307aaceSEvan Bacon modificationTime: number; 2196b7802baSBartosz Kaszubowski /** 2206b7802baSBartosz Kaszubowski * Present if the `md5` option was truthy. Contains the MD5 hash of the file. 2216b7802baSBartosz Kaszubowski */ 2222307aaceSEvan Bacon md5?: string; 2236b7802baSBartosz Kaszubowski } | 2246b7802baSBartosz Kaszubowski /** 2256b7802baSBartosz Kaszubowski * Object returned when file do not exist. 2266b7802baSBartosz Kaszubowski */ 2276b7802baSBartosz Kaszubowski { 2282307aaceSEvan Bacon exists: false; 229eed6b87bSStanisław Chmiela uri: string; 2302307aaceSEvan Bacon isDirectory: false; 2312307aaceSEvan Bacon }; 2326b7802baSBartosz Kaszubowski/* eslint-enable */ 2332307aaceSEvan Bacon 2346b7802baSBartosz Kaszubowski/** 2356b7802baSBartosz Kaszubowski * These values can be used to define how file system data is read / written. 2366b7802baSBartosz Kaszubowski */ 2372307aaceSEvan Baconexport enum EncodingType { 2386b7802baSBartosz Kaszubowski /** 2396b7802baSBartosz Kaszubowski * Standard encoding format. 2406b7802baSBartosz Kaszubowski */ 2412307aaceSEvan Bacon UTF8 = 'utf8', 2426b7802baSBartosz Kaszubowski /** 2436b7802baSBartosz Kaszubowski * Binary, radix-64 representation. 2446b7802baSBartosz Kaszubowski */ 2452307aaceSEvan Bacon Base64 = 'base64', 2462307aaceSEvan Bacon} 2472307aaceSEvan Bacon 2486b7802baSBartosz Kaszubowski// @docsMissing 249da65a760SŁukasz Kosmatyexport type FileSystemAcceptedUploadHttpMethod = 'POST' | 'PUT' | 'PATCH'; 250da65a760SŁukasz Kosmaty 2512307aaceSEvan Baconexport type ReadingOptions = { 2526b7802baSBartosz Kaszubowski /** 2536b7802baSBartosz Kaszubowski * The encoding format to use when reading the file. 2546b7802baSBartosz Kaszubowski * @default EncodingType.UTF8 2556b7802baSBartosz Kaszubowski */ 2562307aaceSEvan Bacon encoding?: EncodingType | 'utf8' | 'base64'; 2576b7802baSBartosz Kaszubowski /** 2586b7802baSBartosz Kaszubowski * Optional number of bytes to skip. This option is only used when `encoding: FileSystem.EncodingType.Base64` and `length` is defined. 2596b7802baSBartosz Kaszubowski * */ 2602307aaceSEvan Bacon position?: number; 2616b7802baSBartosz Kaszubowski /** 2626b7802baSBartosz Kaszubowski * Optional number of bytes to read. This option is only used when `encoding: FileSystem.EncodingType.Base64` and `position` is defined. 2636b7802baSBartosz Kaszubowski */ 2642307aaceSEvan Bacon length?: number; 2652307aaceSEvan Bacon}; 2662307aaceSEvan Bacon 2672307aaceSEvan Baconexport type WritingOptions = { 2686b7802baSBartosz Kaszubowski /** 2696b7802baSBartosz Kaszubowski * The encoding format to use when writing the file. 2706b7802baSBartosz Kaszubowski * @default FileSystem.EncodingType.UTF8 2716b7802baSBartosz Kaszubowski */ 2722307aaceSEvan Bacon encoding?: EncodingType | 'utf8' | 'base64'; 2732307aaceSEvan Bacon}; 2742307aaceSEvan Bacon 2756b7802baSBartosz Kaszubowskiexport type DeletingOptions = { 2766b7802baSBartosz Kaszubowski /** 2776b7802baSBartosz Kaszubowski * If `true`, don't throw an error if there is no file or directory at this URI. 2786b7802baSBartosz Kaszubowski * @default false 2796b7802baSBartosz Kaszubowski */ 2806b7802baSBartosz Kaszubowski idempotent?: boolean; 2816b7802baSBartosz Kaszubowski}; 2826b7802baSBartosz Kaszubowski 2836b7802baSBartosz Kaszubowskiexport type InfoOptions = { 2846b7802baSBartosz Kaszubowski /** 2856b7802baSBartosz Kaszubowski * Whether to return the MD5 hash of the file. 2866b7802baSBartosz Kaszubowski * @default false 2876b7802baSBartosz Kaszubowski */ 2886b7802baSBartosz Kaszubowski md5?: boolean; 2896b7802baSBartosz Kaszubowski /** 2906b7802baSBartosz Kaszubowski * Explicitly specify that the file size should be included. For example, skipping this can prevent downloading the file if it's stored in iCloud. 2916b7802baSBartosz Kaszubowski * The size is always returned for `file://` locations. 2926b7802baSBartosz Kaszubowski */ 2936b7802baSBartosz Kaszubowski size?: boolean; 2946b7802baSBartosz Kaszubowski}; 2956b7802baSBartosz Kaszubowski 2966b7802baSBartosz Kaszubowskiexport type RelocatingOptions = { 2976b7802baSBartosz Kaszubowski /** 2986b7802baSBartosz Kaszubowski * URI or [SAF](#saf-uri) URI to the asset, file, or directory. See [supported URI schemes](#supported-uri-schemes-1). 2996b7802baSBartosz Kaszubowski */ 3006b7802baSBartosz Kaszubowski from: string; 3016b7802baSBartosz Kaszubowski /** 3026b7802baSBartosz Kaszubowski * `file://` URI to the file or directory which should be its new location. 3036b7802baSBartosz Kaszubowski */ 3046b7802baSBartosz Kaszubowski to: string; 3056b7802baSBartosz Kaszubowski}; 3066b7802baSBartosz Kaszubowski 3076b7802baSBartosz Kaszubowskiexport type MakeDirectoryOptions = { 3086b7802baSBartosz Kaszubowski /** 3096b7802baSBartosz Kaszubowski * If `true`, don't throw an error if there is no file or directory at this URI. 3106b7802baSBartosz Kaszubowski * @default false 3116b7802baSBartosz Kaszubowski */ 3126b7802baSBartosz Kaszubowski intermediates?: boolean; 3136b7802baSBartosz Kaszubowski}; 3146b7802baSBartosz Kaszubowski 3156b7802baSBartosz Kaszubowski// @docsMissing 31652eeb172SŁukasz Kosmatyexport type ProgressEvent<T> = { 3172307aaceSEvan Bacon uuid: string; 31852eeb172SŁukasz Kosmaty data: T; 3192307aaceSEvan Bacon}; 3207e929553SEvan Bacon 3216b7802baSBartosz Kaszubowski/* eslint-disable */ 322400de723SŁukasz Kosmatyexport type FileSystemRequestDirectoryPermissionsResult = 3236b7802baSBartosz Kaszubowski /** 3246b7802baSBartosz Kaszubowski * If the permissions were not granted. 3256b7802baSBartosz Kaszubowski */ 3266b7802baSBartosz Kaszubowski { 327400de723SŁukasz Kosmaty granted: false; 3286b7802baSBartosz Kaszubowski } | 3296b7802baSBartosz Kaszubowski /** 3306b7802baSBartosz Kaszubowski * If the permissions were granted. 3316b7802baSBartosz Kaszubowski */ 3326b7802baSBartosz Kaszubowski { 3336b7802baSBartosz Kaszubowski granted: true; 3346b7802baSBartosz Kaszubowski /** 3356b7802baSBartosz Kaszubowski * The [SAF URI](#saf-uri) to the user's selected directory. Available only if permissions were granted. 3366b7802baSBartosz Kaszubowski */ 3376b7802baSBartosz Kaszubowski directoryUri: string; 338400de723SŁukasz Kosmaty }; 3396b7802baSBartosz Kaszubowski/* eslint-enable */ 340