1export enum FileSystemSessionType { 2 /* 3 * Using this mode means that the downloading/uploading session on the native side will work even if the application is moved to background. 4 * 5 * 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. 6 */ 7 BACKGROUND = 0, 8 /* 9 * 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). 10 * Bringing the application to foreground again would trigger Promise rejection. 11 */ 12 FOREGROUND = 1, 13} 14 15export enum FileSystemUploadType { 16 BINARY_CONTENT = 0, 17 MULTIPART = 1, 18} 19 20export type DownloadOptions = { 21 md5?: boolean; 22 cache?: boolean; 23 headers?: Record<string, string>; 24 /* 25 * iOS only 26 */ 27 sessionType?: FileSystemSessionType; 28}; 29 30export type FileSystemHttpResult = { 31 headers: Record<string, string>; 32 status: number; 33 mimeType: string | null; 34}; 35 36export type FileSystemDownloadResult = FileSystemHttpResult & { 37 uri: string; 38 md5?: string; 39}; 40 41/** 42 * @deprecated Use FileSystemDownloadResult instead. 43 */ 44export type DownloadResult = FileSystemDownloadResult; 45 46export type FileSystemUploadOptions = ( 47 | { 48 uploadType?: FileSystemUploadType.BINARY_CONTENT; 49 } 50 | { 51 uploadType: FileSystemUploadType.MULTIPART; 52 fieldName?: string; 53 mimeType?: string; 54 parameters?: Record<string, string>; 55 } 56) & { 57 headers?: Record<string, string>; 58 httpMethod?: FileSystemAcceptedUploadHttpMethod; 59 sessionType?: FileSystemSessionType; 60}; 61 62export type FileSystemUploadResult = FileSystemHttpResult & { 63 body: string; 64}; 65 66export type DownloadProgressCallback = (data: DownloadProgressData) => void; 67 68export type DownloadProgressData = { 69 totalBytesWritten: number; 70 totalBytesExpectedToWrite: number; 71}; 72 73export type DownloadPauseState = { 74 url: string; 75 fileUri: string; 76 options: DownloadOptions; 77 resumeData?: string; 78}; 79 80export type FileInfo = 81 | { 82 exists: true; 83 uri: string; 84 size: number; 85 isDirectory: boolean; 86 modificationTime: number; 87 md5?: string; 88 } 89 | { 90 exists: false; 91 uri: string; 92 size: undefined; 93 isDirectory: false; 94 modificationTime: undefined; 95 md5: undefined; 96 }; 97 98export enum EncodingType { 99 UTF8 = 'utf8', 100 Base64 = 'base64', 101} 102 103export type FileSystemAcceptedUploadHttpMethod = 'POST' | 'PUT' | 'PATCH'; 104 105export type ReadingOptions = { 106 encoding?: EncodingType | 'utf8' | 'base64'; 107 position?: number; 108 length?: number; 109}; 110 111export type WritingOptions = { 112 encoding?: EncodingType | 'utf8' | 'base64'; 113}; 114 115export type ProgressEvent = { 116 uuid: string; 117 data: { 118 totalBytesWritten: number; 119 totalBytesExpectedToWrite: number; 120 }; 121}; 122 123type PlatformMethod = (...args: any[]) => Promise<any>; 124 125export interface ExponentFileSystemModule { 126 readonly name: 'ExponentFileSystem'; 127 readonly documentDirectory: string | null; 128 readonly cacheDirectory: string | null; 129 readonly bundledAssets: string | null; 130 readonly bundleDirectory: string | null; 131 readonly getInfoAsync?: PlatformMethod; 132 readonly readAsStringAsync?: PlatformMethod; 133 readonly writeAsStringAsync?: PlatformMethod; 134 readonly deleteAsync?: PlatformMethod; 135 readonly moveAsync?: PlatformMethod; 136 readonly copyAsync?: PlatformMethod; 137 readonly makeDirectoryAsync?: PlatformMethod; 138 readonly readDirectoryAsync?: PlatformMethod; 139 readonly downloadAsync?: PlatformMethod; 140 readonly uploadAsync?: PlatformMethod; 141 readonly downloadResumableStartAsync?: PlatformMethod; 142 readonly downloadResumablePauseAsync?: PlatformMethod; 143 readonly getContentUriAsync?: PlatformMethod; 144 readonly getFreeDiskStorageAsync?: PlatformMethod; 145 readonly getTotalDiskCapacityAsync?: PlatformMethod; 146 startObserving?: () => void; 147 stopObserving?: () => void; 148 addListener: (eventName: string) => void; 149 removeListeners: (count: number) => void; 150} 151