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 * The total bytes expected to be sent by the upload operation. 152 */ 153 totalBytesExpectedToSend: number; 154}; 155export type DownloadPauseState = { 156 /** 157 * The remote URI to download from. 158 */ 159 url: string; 160 /** 161 * 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. 162 */ 163 fileUri: string; 164 /** 165 * Object representing the file download options. 166 */ 167 options: DownloadOptions; 168 /** 169 * The string which allows the API to resume a paused download. 170 */ 171 resumeData?: string; 172}; 173export type FileInfo = 174/** 175 * Object returned when file exist. 176 */ 177{ 178 /** 179 * Signifies that the requested file exist. 180 */ 181 exists: true; 182 /** 183 * A `file://` URI pointing to the file. This is the same as the `fileUri` input parameter. 184 */ 185 uri: string; 186 /** 187 * 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. 188 */ 189 size: number; 190 /** 191 * Boolean set to `true` if this is a directory and `false` if it is a file. 192 */ 193 isDirectory: boolean; 194 /** 195 * The last modification time of the file expressed in seconds since epoch. 196 */ 197 modificationTime: number; 198 /** 199 * Present if the `md5` option was truthy. Contains the MD5 hash of the file. 200 */ 201 md5?: string; 202} | 203/** 204 * Object returned when file do not exist. 205 */ 206{ 207 exists: false; 208 uri: string; 209 isDirectory: false; 210}; 211/** 212 * These values can be used to define how file system data is read / written. 213 */ 214export declare enum EncodingType { 215 /** 216 * Standard encoding format. 217 */ 218 UTF8 = "utf8", 219 /** 220 * Binary, radix-64 representation. 221 */ 222 Base64 = "base64" 223} 224export type FileSystemAcceptedUploadHttpMethod = 'POST' | 'PUT' | 'PATCH'; 225export type ReadingOptions = { 226 /** 227 * The encoding format to use when reading the file. 228 * @default EncodingType.UTF8 229 */ 230 encoding?: EncodingType | 'utf8' | 'base64'; 231 /** 232 * Optional number of bytes to skip. This option is only used when `encoding: FileSystem.EncodingType.Base64` and `length` is defined. 233 * */ 234 position?: number; 235 /** 236 * Optional number of bytes to read. This option is only used when `encoding: FileSystem.EncodingType.Base64` and `position` is defined. 237 */ 238 length?: number; 239}; 240export type WritingOptions = { 241 /** 242 * The encoding format to use when writing the file. 243 * @default FileSystem.EncodingType.UTF8 244 */ 245 encoding?: EncodingType | 'utf8' | 'base64'; 246}; 247export type DeletingOptions = { 248 /** 249 * If `true`, don't throw an error if there is no file or directory at this URI. 250 * @default false 251 */ 252 idempotent?: boolean; 253}; 254export type InfoOptions = { 255 /** 256 * Whether to return the MD5 hash of the file. 257 * @default false 258 */ 259 md5?: boolean; 260 /** 261 * Explicitly specify that the file size should be included. For example, skipping this can prevent downloading the file if it's stored in iCloud. 262 * The size is always returned for `file://` locations. 263 */ 264 size?: boolean; 265}; 266export type RelocatingOptions = { 267 /** 268 * URI or [SAF](#saf-uri) URI to the asset, file, or directory. See [supported URI schemes](#supported-uri-schemes-1). 269 */ 270 from: string; 271 /** 272 * `file://` URI to the file or directory which should be its new location. 273 */ 274 to: string; 275}; 276export type MakeDirectoryOptions = { 277 /** 278 * If `true`, don't throw an error if there is no file or directory at this URI. 279 * @default false 280 */ 281 intermediates?: boolean; 282}; 283export type ProgressEvent<T> = { 284 uuid: string; 285 data: T; 286}; 287export type FileSystemRequestDirectoryPermissionsResult = 288/** 289 * If the permissions were not granted. 290 */ 291{ 292 granted: false; 293} | 294/** 295 * If the permissions were granted. 296 */ 297{ 298 granted: true; 299 /** 300 * The [SAF URI](#saf-uri) to the user's selected directory. Available only if permissions were granted. 301 */ 302 directoryUri: string; 303}; 304//# sourceMappingURL=FileSystem.types.d.ts.map