1 | export enum FileSystemSessionType {
|
2 | |
3 |
|
4 |
|
5 |
|
6 |
|
7 | BACKGROUND = 0,
|
8 | |
9 |
|
10 |
|
11 |
|
12 | FOREGROUND = 1,
|
13 | }
|
14 |
|
15 | export enum FileSystemUploadType {
|
16 | BINARY_CONTENT = 0,
|
17 | MULTIPART = 1,
|
18 | }
|
19 |
|
20 | export type DownloadOptions = {
|
21 | md5?: boolean;
|
22 | cache?: boolean;
|
23 | headers?: Record<string, string>;
|
24 | |
25 |
|
26 |
|
27 | sessionType?: FileSystemSessionType;
|
28 | };
|
29 |
|
30 | export type FileSystemHttpResult = {
|
31 | headers: Record<string, string>;
|
32 | status: number;
|
33 | mimeType: string | null;
|
34 | };
|
35 |
|
36 | export type FileSystemDownloadResult = FileSystemHttpResult & {
|
37 | uri: string;
|
38 | md5?: string;
|
39 | };
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | export type DownloadResult = FileSystemDownloadResult;
|
45 |
|
46 | export 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 |
|
62 | export type FileSystemUploadResult = FileSystemHttpResult & {
|
63 | body: string;
|
64 | };
|
65 |
|
66 | export type DownloadProgressCallback = (data: DownloadProgressData) => void;
|
67 |
|
68 | export type DownloadProgressData = {
|
69 | totalBytesWritten: number;
|
70 | totalBytesExpectedToWrite: number;
|
71 | };
|
72 |
|
73 | export type DownloadPauseState = {
|
74 | url: string;
|
75 | fileUri: string;
|
76 | options: DownloadOptions;
|
77 | resumeData?: string;
|
78 | };
|
79 |
|
80 | export 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 |
|
98 | export enum EncodingType {
|
99 | UTF8 = 'utf8',
|
100 | Base64 = 'base64',
|
101 | }
|
102 |
|
103 | export type FileSystemAcceptedUploadHttpMethod = 'POST' | 'PUT' | 'PATCH';
|
104 |
|
105 | export type ReadingOptions = {
|
106 | encoding?: EncodingType | 'utf8' | 'base64';
|
107 | position?: number;
|
108 | length?: number;
|
109 | };
|
110 |
|
111 | export type WritingOptions = {
|
112 | encoding?: EncodingType | 'utf8' | 'base64';
|
113 | };
|
114 |
|
115 | export type ProgressEvent = {
|
116 | uuid: string;
|
117 | data: {
|
118 | totalBytesWritten: number;
|
119 | totalBytesExpectedToWrite: number;
|
120 | };
|
121 | };
|
122 |
|
123 | export type FileSystemRequestDirectoryPermissionsResult =
|
124 | | {
|
125 | granted: true;
|
126 | directoryUri: string;
|
127 | }
|
128 | | {
|
129 | granted: false;
|
130 | };
|
131 |
|
132 | type PlatformMethod = (...args: any[]) => Promise<any>;
|
133 |
|
134 | export interface ExponentFileSystemModule {
|
135 | readonly name: 'ExponentFileSystem';
|
136 | readonly documentDirectory: string | null;
|
137 | readonly cacheDirectory: string | null;
|
138 | readonly bundledAssets: string | null;
|
139 | readonly bundleDirectory: string | null;
|
140 | readonly getInfoAsync?: PlatformMethod;
|
141 | readonly readAsStringAsync?: PlatformMethod;
|
142 | readonly writeAsStringAsync?: PlatformMethod;
|
143 | readonly deleteAsync?: PlatformMethod;
|
144 | readonly moveAsync?: PlatformMethod;
|
145 | readonly copyAsync?: PlatformMethod;
|
146 | readonly makeDirectoryAsync?: PlatformMethod;
|
147 | readonly readDirectoryAsync?: PlatformMethod;
|
148 | readonly downloadAsync?: PlatformMethod;
|
149 | readonly uploadAsync?: PlatformMethod;
|
150 | readonly downloadResumableStartAsync?: PlatformMethod;
|
151 | readonly downloadResumablePauseAsync?: PlatformMethod;
|
152 | readonly getContentUriAsync?: PlatformMethod;
|
153 | readonly getFreeDiskStorageAsync?: PlatformMethod;
|
154 | readonly getTotalDiskCapacityAsync?: PlatformMethod;
|
155 | readonly requestDirectoryPermissionsAsync?: PlatformMethod;
|
156 | readonly readSAFDirectoryAsync?: PlatformMethod;
|
157 | readonly makeSAFDirectoryAsync?: PlatformMethod;
|
158 | readonly createSAFFileAsync?: PlatformMethod;
|
159 | startObserving?: () => void;
|
160 | stopObserving?: () => void;
|
161 | addListener: (eventName: string) => void;
|
162 | removeListeners: (count: number) => void;
|
163 | }
|