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