@ohos-ports/react-native-fs 2.20.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +117 -0
- package/FS.common.js +997 -0
- package/LICENSE +21 -0
- package/README.md +765 -0
- package/index.d.ts +294 -0
- package/package.json +48 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
type MkdirOptions = {
|
|
2
|
+
NSURLIsExcludedFromBackupKey?: boolean // iOS only
|
|
3
|
+
NSFileProtectionKey?: string // IOS only
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
type FileOptions = {
|
|
7
|
+
NSFileProtectionKey?: string // IOS only
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type ReadDirItem = {
|
|
11
|
+
ctime: Date | undefined // The creation date of the file (iOS only)
|
|
12
|
+
mtime: Date | undefined // The last modified date of the file
|
|
13
|
+
name: string // The name of the item
|
|
14
|
+
path: string // The absolute path to the item
|
|
15
|
+
size: number // Size in bytes
|
|
16
|
+
isFile: () => boolean // Is the file just a file?
|
|
17
|
+
isDirectory: () => boolean // Is the file a directory?
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type StatResult = {
|
|
21
|
+
name: string | undefined // The name of the item TODO: why is this not documented?
|
|
22
|
+
path: string // The absolute path to the item
|
|
23
|
+
size: number // Size in bytes
|
|
24
|
+
mode: number // UNIX file mode
|
|
25
|
+
ctime: number // Created date
|
|
26
|
+
mtime: number // Last modified date
|
|
27
|
+
originalFilepath: string // In case of content uri this is the pointed file path, otherwise is the same as path
|
|
28
|
+
isFile: () => boolean // Is the file just a file?
|
|
29
|
+
isDirectory: () => boolean // Is the file a directory?
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type Headers = { [name: string]: string }
|
|
33
|
+
type Fields = { [name: string]: string }
|
|
34
|
+
|
|
35
|
+
type DownloadFileOptions = {
|
|
36
|
+
fromUrl: string // URL to download file from
|
|
37
|
+
toFile: string // Local filesystem path to save the file to
|
|
38
|
+
headers?: Headers // An object of headers to be passed to the server
|
|
39
|
+
background?: boolean // Continue the download in the background after the app terminates (iOS only)
|
|
40
|
+
discretionary?: boolean // Allow the OS to control the timing and speed of the download to improve perceived performance (iOS only)
|
|
41
|
+
cacheable?: boolean // Whether the download can be stored in the shared NSURLCache (iOS only)
|
|
42
|
+
progressInterval?: number
|
|
43
|
+
progressDivider?: number
|
|
44
|
+
begin?: (res: DownloadBeginCallbackResult) => void
|
|
45
|
+
progress?: (res: DownloadProgressCallbackResult) => void
|
|
46
|
+
resumable?: () => void // only supported on iOS yet
|
|
47
|
+
connectionTimeout?: number // only supported on Android yet
|
|
48
|
+
readTimeout?: number // supported on Android and iOS
|
|
49
|
+
backgroundTimeout?: number // Maximum time (in milliseconds) to download an entire resource (iOS only, useful for timing out background downloads)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type DownloadBeginCallbackResult = {
|
|
53
|
+
jobId: number // The download job ID, required if one wishes to cancel the download. See `stopDownload`.
|
|
54
|
+
statusCode: number // The HTTP status code
|
|
55
|
+
contentLength: number // The total size in bytes of the download resource
|
|
56
|
+
headers: Headers // The HTTP response headers from the server
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type DownloadProgressCallbackResult = {
|
|
60
|
+
jobId: number // The download job ID, required if one wishes to cancel the download. See `stopDownload`.
|
|
61
|
+
contentLength: number // The total size in bytes of the download resource
|
|
62
|
+
bytesWritten: number // The number of bytes written to the file so far
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type DownloadResult = {
|
|
66
|
+
jobId: number // The download job ID, required if one wishes to cancel the download. See `stopDownload`.
|
|
67
|
+
statusCode: number // The HTTP status code
|
|
68
|
+
bytesWritten: number // The number of bytes written to the file
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type UploadFileOptions = {
|
|
72
|
+
toUrl: string // URL to upload file to
|
|
73
|
+
binaryStreamOnly?: boolean // Allow for binary data stream for file to be uploaded without extra headers, Default is 'false'
|
|
74
|
+
files: UploadFileItem[] // An array of objects with the file information to be uploaded.
|
|
75
|
+
headers?: Headers // An object of headers to be passed to the server
|
|
76
|
+
fields?: Fields // An object of fields to be passed to the server
|
|
77
|
+
method?: string // Default is 'POST', supports 'POST' and 'PUT'
|
|
78
|
+
beginCallback?: (res: UploadBeginCallbackResult) => void // deprecated
|
|
79
|
+
progressCallback?: (res: UploadProgressCallbackResult) => void // deprecated
|
|
80
|
+
begin?: (res: UploadBeginCallbackResult) => void
|
|
81
|
+
progress?: (res: UploadProgressCallbackResult) => void
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
type UploadFileItem = {
|
|
85
|
+
name: string // Name of the file, if not defined then filename is used
|
|
86
|
+
filename: string // Name of file
|
|
87
|
+
filepath: string // Path to file
|
|
88
|
+
filetype: string // The mimetype of the file to be uploaded, if not defined it will get mimetype from `filepath` extension
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
type UploadBeginCallbackResult = {
|
|
92
|
+
jobId: number // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`.
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type UploadProgressCallbackResult = {
|
|
96
|
+
jobId: number // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`.
|
|
97
|
+
totalBytesExpectedToSend: number // The total number of bytes that will be sent to the server
|
|
98
|
+
totalBytesSent: number // The number of bytes sent to the server
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
type UploadResult = {
|
|
102
|
+
jobId: number // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`.
|
|
103
|
+
statusCode: number // The HTTP status code
|
|
104
|
+
headers: Headers // The HTTP response headers from the server
|
|
105
|
+
body: string // The HTTP response body
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
type FSInfoResult = {
|
|
109
|
+
totalSpace: number // The total amount of storage space on the device (in bytes).
|
|
110
|
+
freeSpace: number // The amount of available storage space on the device (in bytes).
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function mkdir(filepath: string, options?: MkdirOptions): Promise<void>
|
|
114
|
+
export function moveFile(
|
|
115
|
+
filepath: string,
|
|
116
|
+
destPath: string,
|
|
117
|
+
options?: FileOptions
|
|
118
|
+
): Promise<void>
|
|
119
|
+
export function copyFile(
|
|
120
|
+
filepath: string,
|
|
121
|
+
destPath: string,
|
|
122
|
+
options?: FileOptions
|
|
123
|
+
): Promise<void>
|
|
124
|
+
export function pathForBundle(bundleNamed: string): Promise<string>
|
|
125
|
+
export function pathForGroup(groupName: string): Promise<string>
|
|
126
|
+
export function getFSInfo(): Promise<FSInfoResult>
|
|
127
|
+
export function getAllExternalFilesDirs(): Promise<string[]>
|
|
128
|
+
export function unlink(filepath: string): Promise<void>
|
|
129
|
+
export function exists(filepath: string): Promise<boolean>
|
|
130
|
+
|
|
131
|
+
export function stopDownload(jobId: number): void
|
|
132
|
+
|
|
133
|
+
export function resumeDownload(jobId: number): void
|
|
134
|
+
|
|
135
|
+
export function isResumable(jobId: number): Promise<boolean>
|
|
136
|
+
|
|
137
|
+
export function stopUpload(jobId: number): void
|
|
138
|
+
|
|
139
|
+
export function completeHandlerIOS(jobId: number): void
|
|
140
|
+
|
|
141
|
+
export function readDir(dirpath: string): Promise<ReadDirItem[]>
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Android-only
|
|
145
|
+
*/
|
|
146
|
+
export function scanFile(path: string): Promise<string[]>
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Android-only
|
|
150
|
+
*/
|
|
151
|
+
export function readDirAssets(dirpath: string): Promise<ReadDirItem[]>
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Android-only
|
|
155
|
+
*/
|
|
156
|
+
export function existsAssets(filepath: string): Promise<boolean>
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Android-only
|
|
160
|
+
*/
|
|
161
|
+
export function existsRes(filepath: string): Promise<boolean>
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Node style version (lowercase d). Returns just the names
|
|
165
|
+
*/
|
|
166
|
+
export function readdir(dirpath: string): Promise<string[]>
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Android-only
|
|
170
|
+
*/
|
|
171
|
+
export function setReadable(
|
|
172
|
+
filepath: string,
|
|
173
|
+
readable: boolean,
|
|
174
|
+
ownerOnly: boolean
|
|
175
|
+
): Promise<boolean>
|
|
176
|
+
|
|
177
|
+
export function stat(filepath: string): Promise<StatResult>
|
|
178
|
+
|
|
179
|
+
export function readFile(
|
|
180
|
+
filepath: string,
|
|
181
|
+
encodingOrOptions?: any
|
|
182
|
+
): Promise<string>
|
|
183
|
+
export function read(
|
|
184
|
+
filepath: string,
|
|
185
|
+
length?: number,
|
|
186
|
+
position?: number,
|
|
187
|
+
encodingOrOptions?: any
|
|
188
|
+
): Promise<string>
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Android only
|
|
192
|
+
*/
|
|
193
|
+
export function readFileAssets(
|
|
194
|
+
filepath: string,
|
|
195
|
+
encodingOrOptions?: any
|
|
196
|
+
): Promise<string>
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Android only
|
|
200
|
+
*/
|
|
201
|
+
export function readFileRes(
|
|
202
|
+
filepath: string,
|
|
203
|
+
encodingOrOptions?: any
|
|
204
|
+
): Promise<string>
|
|
205
|
+
|
|
206
|
+
export function hash(filepath: string, algorithm: string): Promise<string>
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Android only
|
|
210
|
+
*/
|
|
211
|
+
export function copyFileAssets(
|
|
212
|
+
filepath: string,
|
|
213
|
+
destPath: string
|
|
214
|
+
): Promise<void>
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Android only
|
|
218
|
+
*/
|
|
219
|
+
export function copyFileRes(
|
|
220
|
+
filepath: string,
|
|
221
|
+
destPath: string
|
|
222
|
+
): Promise<void>
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* iOS only
|
|
226
|
+
* Copies fotos from asset-library (camera-roll) to a specific location
|
|
227
|
+
* with a given width or height
|
|
228
|
+
* @see: https://developer.apple.com/reference/photos/phimagemanager/1616964-requestimageforasset
|
|
229
|
+
*/
|
|
230
|
+
export function copyAssetsFileIOS(
|
|
231
|
+
imageUri: string,
|
|
232
|
+
destPath: string,
|
|
233
|
+
width: number,
|
|
234
|
+
height: number,
|
|
235
|
+
scale?: number,
|
|
236
|
+
compression?: number,
|
|
237
|
+
resizeMode?: string
|
|
238
|
+
): Promise<string>
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* iOS only
|
|
242
|
+
* Copies fotos from asset-library (camera-roll) to a specific location
|
|
243
|
+
* with a given width or height
|
|
244
|
+
* @see: https://developer.apple.com/reference/photos/phimagemanager/1616964-requestimageforasset
|
|
245
|
+
*/
|
|
246
|
+
export function copyAssetsVideoIOS(
|
|
247
|
+
imageUri: string,
|
|
248
|
+
destPath: string
|
|
249
|
+
): Promise<string>
|
|
250
|
+
|
|
251
|
+
export function writeFile(
|
|
252
|
+
filepath: string,
|
|
253
|
+
contents: string,
|
|
254
|
+
encodingOrOptions?: any
|
|
255
|
+
): Promise<void>
|
|
256
|
+
|
|
257
|
+
export function appendFile(
|
|
258
|
+
filepath: string,
|
|
259
|
+
contents: string,
|
|
260
|
+
encodingOrOptions?: string
|
|
261
|
+
): Promise<void>
|
|
262
|
+
|
|
263
|
+
export function write(
|
|
264
|
+
filepath: string,
|
|
265
|
+
contents: string,
|
|
266
|
+
position?: number,
|
|
267
|
+
encodingOrOptions?: any
|
|
268
|
+
): Promise<void>
|
|
269
|
+
|
|
270
|
+
export function downloadFile(
|
|
271
|
+
options: DownloadFileOptions
|
|
272
|
+
): { jobId: number; promise: Promise<DownloadResult> }
|
|
273
|
+
|
|
274
|
+
export function uploadFiles(
|
|
275
|
+
options: UploadFileOptions
|
|
276
|
+
): { jobId: number; promise: Promise<UploadResult> }
|
|
277
|
+
|
|
278
|
+
export function touch(
|
|
279
|
+
filepath: string,
|
|
280
|
+
mtime?: Date,
|
|
281
|
+
ctime?: Date
|
|
282
|
+
): Promise<void>
|
|
283
|
+
|
|
284
|
+
export const MainBundlePath: string
|
|
285
|
+
export const CachesDirectoryPath: string
|
|
286
|
+
export const ExternalCachesDirectoryPath: string
|
|
287
|
+
export const DownloadDirectoryPath: string
|
|
288
|
+
export const DocumentDirectoryPath: string
|
|
289
|
+
export const ExternalDirectoryPath: string
|
|
290
|
+
export const ExternalStorageDirectoryPath: string
|
|
291
|
+
export const TemporaryDirectoryPath: string
|
|
292
|
+
export const LibraryDirectoryPath: string
|
|
293
|
+
export const PicturesDirectoryPath: string
|
|
294
|
+
export const FileProtectionKeys: string
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ohos-ports/react-native-fs",
|
|
3
|
+
"version": "2.20.0-beta.0",
|
|
4
|
+
"description": "Native filesystem access for react-native — HarmonyOS Node.js port (node:fs/node:http bridge)",
|
|
5
|
+
"main": "FS.common.js",
|
|
6
|
+
"typings": "index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/ohos-ports/ohos-ports.git",
|
|
13
|
+
"directory": "ports/react-native-fs/2.20.0"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/ohos-ports/ohos-ports/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"react-component",
|
|
20
|
+
"react-native",
|
|
21
|
+
"ohos",
|
|
22
|
+
"openharmony",
|
|
23
|
+
"harmonyos",
|
|
24
|
+
"fs",
|
|
25
|
+
"filesystem",
|
|
26
|
+
"download",
|
|
27
|
+
"upload",
|
|
28
|
+
"file-transfer"
|
|
29
|
+
],
|
|
30
|
+
"author": "Johannes Lumpe <johannes@lum.pe> (https://github.com/johanneslumpe)",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"files": [
|
|
33
|
+
"FS.common.js",
|
|
34
|
+
"index.d.ts",
|
|
35
|
+
"README.md",
|
|
36
|
+
"LICENSE",
|
|
37
|
+
"CHANGELOG.md"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"base-64": "^0.1.0",
|
|
41
|
+
"utf8": "^3.0.0"
|
|
42
|
+
},
|
|
43
|
+
"harmonyos": {
|
|
44
|
+
"platform": "openharmony",
|
|
45
|
+
"runtime": "nodejs",
|
|
46
|
+
"migration": "Round 1: Flow annotations stripped, NativeModules.RNFSManager bridge rewritten on node:fs/node:http, NativeEventEmitter replaced with node:events"
|
|
47
|
+
}
|
|
48
|
+
}
|