1/** 2 * These values can be used to define how sessions work on iOS. 3 * @platform ios 4 */ 5export declare enum FileSystemSessionType { 6 /** 7 * Using this mode means that the downloading/uploading session on the native side will work even if the application is moved to background. 8 * 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. 9 * > 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. 10 */ 11 BACKGROUND = 0, 12 /** 13 * 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). 14 * Bringing the application to foreground again would trigger Promise rejection. 15 */ 16 FOREGROUND = 1 17} 18export declare enum FileSystemUploadType { 19 /** 20 * The file will be sent as a request's body. The request can't contain additional data. 21 */ 22 BINARY_CONTENT = 0, 23 /** 24 * An [RFC 2387-compliant](https://www.ietf.org/rfc/rfc2387.txt) request body. The provided file will be encoded into HTTP request. 25 * This request can contain additional data represented by [`UploadOptionsMultipart`](#uploadoptionsmultipart) type. 26 */ 27 MULTIPART = 1 28} 29export type DownloadOptions = { 30 /** 31 * 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. 32 * @default false 33 */ 34 md5?: boolean; 35 cache?: boolean; 36 /** 37 * 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. 38 */ 39 headers?: Record<string, string>; 40 /** 41 * 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. 42 * @default FileSystemSessionType.BACKGROUND 43 * @platform ios 44 */ 45 sessionType?: FileSystemSessionType; 46}; 47export type FileSystemHttpResult = { 48 /** 49 * An object containing all the HTTP response header fields and their values for the download network request. 50 * The keys and values of the object are the header names and values respectively. 51 */ 52 headers: Record<string, string>; 53 /** 54 * The HTTP response status code for the download network request. 55 */ 56 status: number; 57 mimeType: string | null; 58}; 59export type FileSystemDownloadResult = FileSystemHttpResult & { 60 /** 61 * A `file://` URI pointing to the file. This is the same as the `fileUri` input parameter. 62 */ 63 uri: string; 64 /** 65 * Present if the `md5` option was truthy. Contains the MD5 hash of the file. 66 */ 67 md5?: string; 68}; 69/** 70 * @deprecated Use `FileSystemDownloadResult` instead. 71 */ 72export type DownloadResult = FileSystemDownloadResult; 73export type FileSystemUploadOptions = (UploadOptionsBinary | UploadOptionsMultipart) & { 74 /** 75 * An object containing all the HTTP header fields and their values for the upload network request. 76 * The keys and values of the object are the header names and values respectively. 77 */ 78 headers?: Record<string, string>; 79 /** 80 * The request method. 81 * @default FileSystemAcceptedUploadHttpMethod.POST 82 */ 83 httpMethod?: FileSystemAcceptedUploadHttpMethod; 84 /** 85 * 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. 86 * @default FileSystemSessionType.BACKGROUND 87 * @platform ios 88 */ 89 sessionType?: FileSystemSessionType; 90}; 91/** 92 * Upload options when upload type is set to binary. 93 */ 94export type UploadOptionsBinary = { 95 /** 96 * Upload type determines how the file will be sent to the server. 97 * Value will be `FileSystemUploadType.BINARY_CONTENT`. 98 */ 99 uploadType?: FileSystemUploadType; 100}; 101/** 102 * Upload options when upload type is set to multipart. 103 */ 104export type UploadOptionsMultipart = { 105 /** 106 * Upload type determines how the file will be sent to the server. 107 * Value will be `FileSystemUploadType.MULTIPART`. 108 */ 109 uploadType: FileSystemUploadType; 110 /** 111 * The name of the field which will hold uploaded file. Defaults to the file name without an extension. 112 */ 113 fieldName?: string; 114 /** 115 * The MIME type of the provided file. If not provided, the module will try to guess it based on the extension. 116 */ 117 mimeType?: string; 118 /** 119 * Additional form properties. They will be located in the request body. 120 */ 121 parameters?: Record<string, string>; 122}; 123export type FileSystemUploadResult = FileSystemHttpResult & { 124 /** 125 * The body of the server response. 126 */ 127 body: string; 128}; 129export type FileSystemNetworkTaskProgressCallback<T extends DownloadProgressData | UploadProgressData> = (data: T) => void; 130/** 131 * @deprecated use `FileSystemNetworkTaskProgressCallback<DownloadProgressData>` instead. 132 */ 133export type DownloadProgressCallback = FileSystemNetworkTaskProgressCallback<DownloadProgressData>; 134export type DownloadProgressData = { 135 /** 136 * The total bytes written by the download operation. 137 */ 138 totalBytesWritten: number; 139 /** 140 * 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 141 * and the total size is unknown. Without this header, you won't be able to track the download progress. 142 */ 143 totalBytesExpectedToWrite: number; 144}; 145export type UploadProgressData = { 146 /** 147 * The total bytes sent by the upload operation. 148 */ 149 totalBytesSent: number; 150 /** 151 * @deprecated Use `totalBytesSent` instead. 152 */ 153 totalByteSent: number; 154 /** 155 * The total bytes expected to be sent by the upload operation. 156 */ 157 totalBytesExpectedToSend: number; 158}; 159export type DownloadPauseState = { 160 /** 161 * The remote URI to download from. 162 */ 163 url: string; 164 /** 165 * 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. 166 */ 167 fileUri: string; 168 /** 169 * Object representing the file download options. 170 */ 171 options: DownloadOptions; 172 /** 173 * The string which allows the API to resume a paused download. 174 */ 175 resumeData?: string; 176}; 177export type FileInfo = 178/** 179 * Object returned when file exist. 180 */ 181{ 182 /** 183 * Signifies that the requested file exist. 184 */ 185 exists: true; 186 /** 187 * A `file://` URI pointing to the file. This is the same as the `fileUri` input parameter. 188 */ 189 uri: string; 190 /** 191 * 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. 192 */ 193 size: number; 194 /** 195 * Boolean set to `true` if this is a directory and `false` if it is a file. 196 */ 197 isDirectory: boolean; 198 /** 199 * The last modification time of the file expressed in seconds since epoch. 200 */ 201 modificationTime: number; 202 /** 203 * Present if the `md5` option was truthy. Contains the MD5 hash of the file. 204 */ 205 md5?: string; 206} | 207/** 208 * Object returned when file do not exist. 209 */ 210{ 211 exists: false; 212 uri: string; 213 isDirectory: false; 214}; 215/** 216 * These values can be used to define how file system data is read / written. 217 */ 218export declare enum EncodingType { 219 /** 220 * Standard encoding format. 221 */ 222 UTF8 = "utf8", 223 /** 224 * Binary, radix-64 representation. 225 */ 226 Base64 = "base64" 227} 228export type FileSystemAcceptedUploadHttpMethod = 'POST' | 'PUT' | 'PATCH'; 229export type ReadingOptions = { 230 /** 231 * The encoding format to use when reading the file. 232 * @default EncodingType.UTF8 233 */ 234 encoding?: EncodingType | 'utf8' | 'base64'; 235 /** 236 * Optional number of bytes to skip. This option is only used when `encoding: FileSystem.EncodingType.Base64` and `length` is defined. 237 * */ 238 position?: number; 239 /** 240 * Optional number of bytes to read. This option is only used when `encoding: FileSystem.EncodingType.Base64` and `position` is defined. 241 */ 242 length?: number; 243}; 244export type WritingOptions = { 245 /** 246 * The encoding format to use when writing the file. 247 * @default FileSystem.EncodingType.UTF8 248 */ 249 encoding?: EncodingType | 'utf8' | 'base64'; 250}; 251export type DeletingOptions = { 252 /** 253 * If `true`, don't throw an error if there is no file or directory at this URI. 254 * @default false 255 */ 256 idempotent?: boolean; 257}; 258export type InfoOptions = { 259 /** 260 * Whether to return the MD5 hash of the file. 261 * @default false 262 */ 263 md5?: boolean; 264 /** 265 * Explicitly specify that the file size should be included. For example, skipping this can prevent downloading the file if it's stored in iCloud. 266 * The size is always returned for `file://` locations. 267 */ 268 size?: boolean; 269}; 270export type RelocatingOptions = { 271 /** 272 * URI or [SAF](#saf-uri) URI to the asset, file, or directory. See [supported URI schemes](#supported-uri-schemes-1). 273 */ 274 from: string; 275 /** 276 * `file://` URI to the file or directory which should be its new location. 277 */ 278 to: string; 279}; 280export type MakeDirectoryOptions = { 281 /** 282 * If `true`, don't throw an error if there is no file or directory at this URI. 283 * @default false 284 */ 285 intermediates?: boolean; 286}; 287export type ProgressEvent<T> = { 288 uuid: string; 289 data: T; 290}; 291export type FileSystemRequestDirectoryPermissionsResult = 292/** 293 * If the permissions were not granted. 294 */ 295{ 296 granted: false; 297} | 298/** 299 * If the permissions were granted. 300 */ 301{ 302 granted: true; 303 /** 304 * The [SAF URI](#saf-uri) to the user's selected directory. Available only if permissions were granted. 305 */ 306 directoryUri: string; 307}; 308//# sourceMappingURL=FileSystem.types.d.ts.map