1 | import { IonicNativePlugin } from '@ionic-native/core';
|
2 | export interface IFile extends Blob {
|
3 | |
4 |
|
5 |
|
6 | name: string;
|
7 | |
8 |
|
9 |
|
10 | lastModified: number;
|
11 | |
12 |
|
13 |
|
14 | lastModifiedDate: number;
|
15 | |
16 |
|
17 |
|
18 | size: number;
|
19 | |
20 |
|
21 |
|
22 | type: string;
|
23 | localURL: string;
|
24 | start: number;
|
25 | end: number;
|
26 | |
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | slice(start: number, end: number): Blob;
|
34 | }
|
35 | export interface LocalFileSystem {
|
36 | |
37 |
|
38 |
|
39 | TEMPORARY: number;
|
40 | |
41 |
|
42 |
|
43 | PERSISTENT: number;
|
44 | |
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | requestFileSystem(type: number, size: number, successCallback: FileSystemCallback, errorCallback?: ErrorCallback): void;
|
54 | |
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | resolveLocalFileSystemURL(url: string, successCallback: FileEntryCallback, errorCallback?: ErrorCallback): void;
|
62 | |
63 |
|
64 |
|
65 | webkitRequestFileSystem(type: number, size: number, successCallback: FileSystemCallback, errorCallback?: ErrorCallback): void;
|
66 | }
|
67 | export interface Metadata {
|
68 | |
69 |
|
70 |
|
71 |
|
72 | modificationTime: Date;
|
73 | |
74 |
|
75 |
|
76 |
|
77 | size: number;
|
78 | }
|
79 | export interface Flags {
|
80 | |
81 |
|
82 |
|
83 | create?: boolean;
|
84 | |
85 |
|
86 |
|
87 |
|
88 | exclusive?: boolean;
|
89 | }
|
90 |
|
91 |
|
92 |
|
93 | export interface FileSystem {
|
94 | |
95 |
|
96 |
|
97 |
|
98 |
|
99 | name: string;
|
100 | |
101 |
|
102 |
|
103 |
|
104 | root: DirectoryEntry;
|
105 | toJSON(): string;
|
106 | encodeURIPath(path: string): string;
|
107 | }
|
108 | export interface Entry {
|
109 | |
110 |
|
111 |
|
112 | isFile: boolean;
|
113 | |
114 |
|
115 |
|
116 | isDirectory: boolean;
|
117 | |
118 |
|
119 |
|
120 |
|
121 |
|
122 | getMetadata(successCallback: MetadataCallback, errorCallback?: ErrorCallback): void;
|
123 | |
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 | setMetadata(successCallback: MetadataCallback, errorCallback: ErrorCallback, metadataObject: Metadata): void;
|
130 | |
131 |
|
132 |
|
133 | name: string;
|
134 | |
135 |
|
136 |
|
137 | fullPath: string;
|
138 | |
139 |
|
140 |
|
141 | filesystem: FileSystem;
|
142 | |
143 |
|
144 |
|
145 | nativeURL: string;
|
146 | |
147 |
|
148 |
|
149 |
|
150 |
|
151 | getMetadata(successCallback: MetadataCallback, errorCallback?: ErrorCallback): void;
|
152 | |
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 | setMetadata(successCallback: MetadataCallback, errorCallback: ErrorCallback, metadataObject: Metadata): void;
|
159 | |
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 | moveTo(parent: DirectoryEntry, newName?: string, successCallback?: EntryCallback, errorCallback?: ErrorCallback): void;
|
174 | |
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 | copyTo(parent: DirectoryEntry, newName?: string, successCallback?: EntryCallback, errorCallback?: ErrorCallback): void;
|
191 | |
192 |
|
193 |
|
194 |
|
195 | toURL(): string;
|
196 | |
197 |
|
198 |
|
199 |
|
200 | toInternalURL(): string;
|
201 | |
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 | remove(successCallback: VoidCallback, errorCallback?: ErrorCallback): void;
|
208 | |
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 | getParent(successCallback: DirectoryEntryCallback, errorCallback?: ErrorCallback): void;
|
215 | }
|
216 |
|
217 |
|
218 |
|
219 | export interface DirectoryEntry extends Entry {
|
220 | |
221 |
|
222 |
|
223 | createReader(): DirectoryReader;
|
224 | |
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 | getFile(path: string, options?: Flags, successCallback?: FileEntryCallback, errorCallback?: ErrorCallback): void;
|
241 | |
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 | getDirectory(path: string, options?: Flags, successCallback?: DirectoryEntryCallback, errorCallback?: ErrorCallback): void;
|
259 | |
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 | removeRecursively(successCallback: VoidCallback, errorCallback?: ErrorCallback): void;
|
267 | }
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 | export interface DirectoryReader {
|
279 | localURL: string;
|
280 | hasReadEntries: boolean;
|
281 | |
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 | readEntries(successCallback: EntriesCallback, errorCallback?: ErrorCallback): void;
|
289 | }
|
290 |
|
291 |
|
292 |
|
293 | export interface FileEntry extends Entry {
|
294 | |
295 |
|
296 |
|
297 |
|
298 |
|
299 | createWriter(successCallback: FileWriterCallback, errorCallback?: ErrorCallback): void;
|
300 | |
301 |
|
302 |
|
303 |
|
304 |
|
305 | file(successCallback: FileCallback, errorCallback?: ErrorCallback): void;
|
306 | }
|
307 |
|
308 |
|
309 |
|
310 | export declare type FileSystemCallback = (filesystem: FileSystem) => void;
|
311 |
|
312 |
|
313 |
|
314 | export declare type EntryCallback = (entry: Entry) => void;
|
315 |
|
316 |
|
317 |
|
318 | export declare type FileEntryCallback = (entry: FileEntry) => void;
|
319 |
|
320 |
|
321 |
|
322 | export declare type DirectoryEntryCallback = (entry: DirectoryEntry) => void;
|
323 |
|
324 |
|
325 |
|
326 | export declare type EntriesCallback = (entries: Entry[]) => void;
|
327 |
|
328 |
|
329 |
|
330 | export declare type MetadataCallback = (metadata: Metadata) => void;
|
331 |
|
332 |
|
333 |
|
334 | export declare type FileWriterCallback = (fileWriter: FileWriter) => void;
|
335 |
|
336 |
|
337 |
|
338 | export declare type FileCallback = (file: IFile) => void;
|
339 |
|
340 |
|
341 |
|
342 | export declare type VoidCallback = () => void;
|
343 |
|
344 |
|
345 |
|
346 | export declare type ErrorCallback = (err: FileError) => void;
|
347 | export interface RemoveResult {
|
348 | success: boolean;
|
349 | fileRemoved: Entry;
|
350 | }
|
351 |
|
352 | export declare class FileSaver extends EventTarget {
|
353 | |
354 |
|
355 |
|
356 |
|
357 |
|
358 | constructor(data: Blob);
|
359 | /**
|
360 | * When the abort method is called, user agents must run the steps below:
|
361 | * <ol>
|
362 | * <li> If readyState == DONE or readyState == INIT, terminate this overall series of steps without doing anything
|
363 | * else. </li>
|
364 | * <li> Set readyState to DONE. </li>
|
365 | * <li> If there are any tasks from the object's FileSaver task source in one of the task queues, then remove those
|
366 | * tasks. </li>
|
367 | * <li> Terminate the write algorithm being processed. </li>
|
368 | * <li> Set the error attribute to a DOMError object of type "AbortError". </li>
|
369 | * <li> Fire a progress event called abort </li>
|
370 | * <li> Fire a progress event called write end </li>
|
371 | * <li> Terminate this algorithm. </li>
|
372 | * </ol>
|
373 | */
|
374 | abort(): void;
|
375 | /**
|
376 | * The blob is being written.
|
377 | * @readonly
|
378 | */
|
379 | INIT: number;
|
380 | /**
|
381 | * The object has been constructed, but there is no pending write.
|
382 | * @readonly
|
383 | */
|
384 | WRITING: number;
|
385 | /**
|
386 | * The entire Blob has been written to the file, an error occurred during the write, or the write was aborted using
|
387 | * abort(). The FileSaver is no longer writing the blob.
|
388 | * @readonly
|
389 | */
|
390 | DONE: number;
|
391 | /**
|
392 | * The FileSaver object can be in one of 3 states. The readyState attribute, on getting, must return the current
|
393 | * state, which must be one of the following values:
|
394 | * <ul>
|
395 | * <li>INIT</li>
|
396 | * <li>WRITING</li>
|
397 | * <li>DONE</li>
|
398 | * <ul>
|
399 | * @readonly
|
400 | */
|
401 | readyState: number;
|
402 | /**
|
403 | * The last error that occurred on the FileSaver.
|
404 | * @readonly
|
405 | */
|
406 | error: Error;
|
407 | /**
|
408 | * Handler for write start events
|
409 | */
|
410 | onwritestart: (event: ProgressEvent) => void;
|
411 | /**
|
412 | * Handler for progress events.
|
413 | */
|
414 | onprogress: (event: ProgressEvent) => void;
|
415 | /**
|
416 | * Handler for write events.
|
417 | */
|
418 | onwrite: (event: ProgressEvent) => void;
|
419 | /**
|
420 | * Handler for abort events.
|
421 | */
|
422 | onabort: (event: ProgressEvent) => void;
|
423 | /**
|
424 | * Handler for error events.
|
425 | */
|
426 | onerror: (event: ProgressEvent) => void;
|
427 | /**
|
428 | * Handler for write end events.
|
429 | */
|
430 | onwriteend: (event: ProgressEvent) => void;
|
431 | /**
|
432 | * When the FileSaver constructor is called, the user agent must return a new FileSaver object with readyState set to
|
433 | * INIT. This constructor must be visible when the script's global object is either a Window object or an object
|
434 | * implementing the WorkerUtils interface.
|
435 | */
|
436 | constructor(data: Blob);
|
437 | /**
|
438 | * When the abort method is called, user agents must run the steps below:
|
439 | * <ol>
|
440 | * <li> If readyState == DONE or readyState == INIT, terminate this overall series of steps without doing anything
|
441 | * else. </li>
|
442 | * <li> Set readyState to DONE. </li>
|
443 | * <li> If there are any tasks from the object's FileSaver task source in one of the task queues, then remove those
|
444 | * tasks. </li>
|
445 | * <li> Terminate the write algorithm being processed. </li>
|
446 | * <li> Set the error attribute to a DOMError object of type "AbortError". </li>
|
447 | * <li> Fire a progress event called abort </li>
|
448 | * <li> Fire a progress event called writeend </li>
|
449 | * <li> Terminate this algorithm. </li>
|
450 | * </ol>
|
451 | */
|
452 | abort(): void;
|
453 | }
|
454 | /**
|
455 | * @hidden
|
456 | * This interface expands on the FileSaver interface to allow for multiple write actions, rather than just saving a
|
457 | * single Blob.
|
458 | */
|
459 | export declare class FileWriter extends FileSaver {
|
460 | /**
|
461 | * The byte offset at which the next write to the file will occur. This must be no greater than length.
|
462 | * A newly-created FileWriter must have position set to 0.
|
463 | */
|
464 | position: number;
|
465 | /**
|
466 | * The length of the file. If the user does not have read access to the file, this must be the highest byte offset at
|
467 | * which the user has written.
|
468 | */
|
469 | length: number;
|
470 | /**
|
471 | * Write the supplied data to the file at position.
|
472 | * @param data The blob to write.
|
473 | */
|
474 | write(data: ArrayBuffer | Blob | string): void;
|
475 | /**
|
476 | * Seek sets the file position at which the next write will occur.
|
477 | * @param offset If nonnegative, an absolute byte offset into the file. If negative, an offset back from the end of
|
478 | * the file.
|
479 | */
|
480 | seek(offset: number): void;
|
481 | /**
|
482 | * Changes the length of the file to that specified. If shortening the file, data beyond the new length must be
|
483 | * discarded. If extending the file, the existing data must be zero-padded up to the new length.
|
484 | * @param size The size to which the length of the file is to be adjusted, measured in bytes.
|
485 | */
|
486 | truncate(size: number): void;
|
487 | }
|
488 | export interface IWriteOptions {
|
489 | replace?: boolean;
|
490 | append?: boolean;
|
491 | truncate?: number;
|
492 | }
|
493 | /** @hidden */
|
494 | export declare class FileError {
|
495 | static NOT_FOUND_ERR: number;
|
496 | static SECURITY_ERR: number;
|
497 | static ABORT_ERR: number;
|
498 | static NOT_READABLE_ERR: number;
|
499 | static ENCODING_ERR: number;
|
500 | static NO_MODIFICATION_ALLOWED_ERR: number;
|
501 | static INVALID_STATE_ERR: number;
|
502 | static SYNTAX_ERR: number;
|
503 | static INVALID_MODIFICATION_ERR: number;
|
504 | static QUOTA_EXCEEDED_ERR: number;
|
505 | static TYPE_MISMATCH_ERR: number;
|
506 | static PATH_EXISTS_ERR: number;
|
507 | /** Error code */
|
508 | code: number;
|
509 | message: string;
|
510 | constructor(code: number);
|
511 | }
|
512 | /** @hidden */
|
513 | export declare class FileReader {
|
514 | static EMPTY: number;
|
515 | static LOADING: number;
|
516 | static DONE: number;
|
517 | static READ_CHUNK_SIZE: number;
|
518 | readyState: number;
|
519 | error: Error;
|
520 | result: string | ArrayBuffer;
|
521 | onloadstart: (evt: ProgressEvent) => void;
|
522 | onprogress: (evt: ProgressEvent) => void;
|
523 | onload: (evt: ProgressEvent) => void;
|
524 | onerror: (evt: ProgressEvent) => void;
|
525 | onloadend: (evt: ProgressEvent) => void;
|
526 | onabort: (evt: ProgressEvent) => void;
|
527 | abort(): void;
|
528 | readAsText(fe: IFile, encoding?: string): void;
|
529 | readAsDataURL(fe: IFile): void;
|
530 | readAsBinaryString(fe: IFile): void;
|
531 | readAsArrayBuffer(fe: IFile): void;
|
532 | /**
|
533 | * @hidden
|
534 | */
|
535 | [key: string]: any;
|
536 | }
|
537 | /**
|
538 | * @name File
|
539 | * @premier filesystem
|
540 | * @description
|
541 | * This plugin implements a File API allowing read/write access to files residing on the device.
|
542 | *
|
543 | * The File class implements static convenience functions to access files and directories.
|
544 | *
|
545 | * Example:
|
546 | * ```
|
547 | * import { File } from '@ionic-native/file/ngx';
|
548 | *
|
549 | * constructor(private file: File) { }
|
550 | *
|
551 | * ...
|
552 | *
|
553 | * this.file.checkDir(this.file.dataDirectory, 'mydir').then(_ => console.log('Directory exists')).catch(err =>
|
554 | * console.log('Directory doesn't exist'));
|
555 | *
|
556 | * ```
|
557 | *
|
558 | * This plugin is based on several specs, including : The HTML5 File API http: //www.w3.org/TR/FileAPI/
|
559 | * The (now-defunct) Directories and System extensions Latest: http: //www.w3.org/TR/2012/WD-file-system-api-20120417/
|
560 | * Although most of the plugin code was written when an earlier spec was current: http:
|
561 | * //www.w3.org/TR/2011/WD-file-system-api-20110419/ It also implements the FileWriter spec : http:
|
562 | * //dev.w3.org/2009/dap/file-system/file-writer.html
|
563 | * @interfaces
|
564 | * IFile
|
565 | * Entry
|
566 | * DirectoryEntry
|
567 | * DirectoryReader
|
568 | * FileSystem
|
569 | */
|
570 | export declare class FileOriginal extends IonicNativePlugin {
|
571 | /**
|
572 | * Read-only directory where the application is installed.
|
573 | */
|
574 | applicationDirectory: string;
|
575 | /**
|
576 | * Read-only directory where the application is installed.
|
577 | */
|
578 | applicationStorageDirectory: string;
|
579 | /**
|
580 | * Where to put app-specific data files.
|
581 | */
|
582 | dataDirectory: string;
|
583 | /**
|
584 | * Cached files that should survive app restarts.
|
585 | * Apps should not rely on the OS to delete files in here.
|
586 | */
|
587 | cacheDirectory: string;
|
588 | /**
|
589 | * Android: the application space on external storage.
|
590 | */
|
591 | externalApplicationStorageDirectory: string;
|
592 | /**
|
593 | * Android: Where to put app-specific data files on external storage.
|
594 | */
|
595 | externalDataDirectory: string;
|
596 | /**
|
597 | * Android: the application cache on external storage.
|
598 | */
|
599 | externalCacheDirectory: string;
|
600 | /**
|
601 | * Android: the external storage (SD card) root.
|
602 | */
|
603 | externalRootDirectory: string;
|
604 | /**
|
605 | * iOS: Temp directory that the OS can clear at will.
|
606 | */
|
607 | tempDirectory: string;
|
608 | /**
|
609 | * iOS: Holds app-specific files that should be synced (e.g. to iCloud).
|
610 | */
|
611 | syncedDataDirectory: string;
|
612 | /**
|
613 | * iOS: Files private to the app, but that are meaningful to other applications (e.g. Office files)
|
614 | */
|
615 | documentsDirectory: string;
|
616 | /**
|
617 | * BlackBerry10: Files globally available to all apps
|
618 | */
|
619 | sharedDirectory: string;
|
620 | cordovaFileError: any;
|
621 | /**
|
622 | * Get free disk space in Bytes
|
623 | * @returns {Promise<number>} Returns a promise that resolves with the remaining free disk space in Bytes
|
624 | */
|
625 | getFreeDiskSpace(): Promise<number>;
|
626 | /**
|
627 | * Check if a directory exists in a certain path, directory.
|
628 | *
|
629 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
|
630 | * @param {string} dir Name of directory to check
|
631 | * @returns {Promise<boolean>} Returns a Promise that resolves to true if the directory exists or rejects with an
|
632 | * error.
|
633 | */
|
634 | checkDir(path: string, dir: string): Promise<boolean>;
|
635 | /**
|
636 | * Creates a new directory in the specific path.
|
637 | * The replace boolean value determines whether to replace an existing directory with the same name.
|
638 | * If an existing directory exists and the replace value is false, the promise will fail and return an error.
|
639 | *
|
640 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
|
641 | * @param {string} dirName Name of directory to create
|
642 | * @param {boolean} replace If true, replaces file with same name. If false returns error
|
643 | * @returns {Promise<DirectoryEntry>} Returns a Promise that resolves with a DirectoryEntry or rejects with an error.
|
644 | */
|
645 | createDir(path: string, dirName: string, replace: boolean): Promise<DirectoryEntry>;
|
646 | /**
|
647 | * Remove a directory at a given path.
|
648 | *
|
649 | * @param {string} path The path to the directory
|
650 | * @param {string} dirName The directory name
|
651 | * @returns {Promise<RemoveResult>} Returns a Promise that resolves to a RemoveResult or rejects with an error.
|
652 | */
|
653 | removeDir(path: string, dirName: string): Promise<RemoveResult>;
|
654 | /**
|
655 | * Move a directory to a given path.
|
656 | *
|
657 | * @param {string} path The source path to the directory
|
658 | * @param {string} dirName The source directory name
|
659 | * @param {string} newPath The destination path to the directory
|
660 | * @param {string} newDirName The destination directory name
|
661 | * @returns {Promise<DirectoryEntry|Entry>} Returns a Promise that resolves to the new DirectoryEntry object or
|
662 | * rejects with an error.
|
663 | */
|
664 | moveDir(path: string, dirName: string, newPath: string, newDirName: string): Promise<DirectoryEntry | Entry>;
|
665 | /**
|
666 | * Copy a directory in various methods. If destination directory exists, will fail to copy.
|
667 | *
|
668 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
669 | * @param {string} dirName Name of directory to copy
|
670 | * @param {string} newPath Base FileSystem of new location
|
671 | * @param {string} newDirName New name of directory to copy to (leave blank to remain the same)
|
672 | * @returns {Promise<Entry>} Returns a Promise that resolves to the new Entry object or rejects with an error.
|
673 | */
|
674 | copyDir(path: string, dirName: string, newPath: string, newDirName: string): Promise<Entry>;
|
675 | /**
|
676 | * List files and directory from a given path.
|
677 | *
|
678 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
679 | * @param {string} dirName Name of directory
|
680 | * @returns {Promise<Entry[]>} Returns a Promise that resolves to an array of Entry objects or rejects with an error.
|
681 | */
|
682 | listDir(path: string, dirName: string): Promise<Entry[]>;
|
683 | /**
|
684 | * Removes all files and the directory from a desired location.
|
685 | *
|
686 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
|
687 | * @param {string} dirName Name of directory
|
688 | * @returns {Promise<RemoveResult>} Returns a Promise that resolves with a RemoveResult or rejects with an error.
|
689 | */
|
690 | removeRecursively(path: string, dirName: string): Promise<RemoveResult>;
|
691 | /**
|
692 | * Check if a file exists in a certain path, directory.
|
693 | *
|
694 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
|
695 | * @param {string} file Name of file to check
|
696 | * @returns {Promise<boolean>} Returns a Promise that resolves with a boolean or rejects with an error.
|
697 | */
|
698 | checkFile(path: string, file: string): Promise<boolean>;
|
699 | /**
|
700 | * Creates a new file in the specific path.
|
701 | * The replace boolean value determines whether to replace an existing file with the same name.
|
702 | * If an existing file exists and the replace value is false, the promise will fail and return an error.
|
703 | *
|
704 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
|
705 | * @param {string} fileName Name of file to create
|
706 | * @param {boolean} replace If true, replaces file with same name. If false returns error
|
707 | * @returns {Promise<FileEntry>} Returns a Promise that resolves to a FileEntry or rejects with an error.
|
708 | */
|
709 | createFile(path: string, fileName: string, replace: boolean): Promise<FileEntry>;
|
710 | /**
|
711 | * Removes a file from a desired location.
|
712 | *
|
713 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
|
714 | * @param {string} fileName Name of file to remove
|
715 | * @returns {Promise<RemoveResult>} Returns a Promise that resolves to a RemoveResult or rejects with an error.
|
716 | */
|
717 | removeFile(path: string, fileName: string): Promise<RemoveResult>;
|
718 | /**
|
719 | * Write a new file to the desired location.
|
720 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
|
721 | * @param {string} fileName path relative to base path
|
722 | * @param {string | Blob | ArrayBuffer} text content, blob or ArrayBuffer to write
|
723 | * @param {IWriteOptions} whether to replace/append to an existing file. See IWriteOptions for more information.
|
724 | * @returns {Promise<any>} Returns a Promise that resolves to updated file entry or rejects with an error.
|
725 | */
|
726 | writeFile(path: string, fileName: string, text: string | Blob | ArrayBuffer, options?: IWriteOptions): Promise<any>;
|
727 | /**
|
728 | * Write content to FileEntry.
|
729 | * @hidden
|
730 | * Write to an existing file.
|
731 | * @param {FileEntry} fe file entry object
|
732 | * @param {string | Blob | ArrayBuffer} text text content or blob to write
|
733 | * @param {IWriteOptions} options replace file if set to true. See WriteOptions for more information.
|
734 | * @returns {Promise<FileEntry>} Returns a Promise that resolves to updated file entry or rejects with an error.
|
735 | */
|
736 | private writeFileEntry;
|
737 | /**
|
738 | * Write to an existing file.
|
739 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
|
740 | * @param {string} fileName path relative to base path
|
741 | * @param {string | Blob} text content or blob to write
|
742 | * @returns {Promise<void>} Returns a Promise that resolves or rejects with an error.
|
743 | */
|
744 | writeExistingFile(path: string, fileName: string, text: string | Blob): Promise<void>;
|
745 | /**
|
746 | * Read the contents of a file as text.
|
747 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
|
748 | * @param {string} file Name of file, relative to path.
|
749 | * @returns {Promise<string>} Returns a Promise that resolves with the contents of the file as string or rejects with
|
750 | * an error.
|
751 | */
|
752 | readAsText(path: string, file: string): Promise<string>;
|
753 | /**
|
754 | * Read file and return data as a base64 encoded data url.
|
755 | * A data url is of the form:
|
756 | * data: [<mediatype>][;base64],<data>
|
757 | *
|
758 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
|
759 | * @param {string} file Name of file, relative to path.
|
760 | * @returns {Promise<string>} Returns a Promise that resolves with the contents of the file as data URL or rejects
|
761 | * with an error.
|
762 | */
|
763 | readAsDataURL(path: string, file: string): Promise<string>;
|
764 | /**
|
765 | * Read file and return data as a binary data.
|
766 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
|
767 | * @param {string} file Name of file, relative to path.
|
768 | * @returns {Promise<string>} Returns a Promise that resolves with the contents of the file as string rejects with an
|
769 | * error.
|
770 | */
|
771 | readAsBinaryString(path: string, file: string): Promise<string>;
|
772 | /**
|
773 | * Read file and return data as an ArrayBuffer.
|
774 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
|
775 | * @param {string} file Name of file, relative to path.
|
776 | * @returns {Promise<ArrayBuffer>} Returns a Promise that resolves with the contents of the file as ArrayBuffer or
|
777 | * rejects with an error.
|
778 | */
|
779 | readAsArrayBuffer(path: string, file: string): Promise<ArrayBuffer>;
|
780 | /**
|
781 | * Move a file to a given path.
|
782 | *
|
783 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
|
784 | * @param {string} fileName Name of file to move
|
785 | * @param {string} newPath Base FileSystem of new location
|
786 | * @param {string} newFileName New name of file to move to (leave blank to remain the same)
|
787 | * @returns {Promise<Entry>} Returns a Promise that resolves to the new Entry or rejects with an error.
|
788 | */
|
789 | moveFile(path: string, fileName: string, newPath: string, newFileName: string): Promise<Entry>;
|
790 | /**
|
791 | * Copy a file in various methods. If file exists, will fail to copy.
|
792 | *
|
793 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
|
794 | * @param {string} fileName Name of file to copy
|
795 | * @param {string} newPath Base FileSystem of new location
|
796 | * @param {string} newFileName New name of file to copy to (leave blank to remain the same)
|
797 | * @returns {Promise<Entry>} Returns a Promise that resolves to an Entry or rejects with an error.
|
798 | */
|
799 | copyFile(path: string, fileName: string, newPath: string, newFileName: string): Promise<Entry>;
|
800 | /**
|
801 | * @hidden
|
802 | */
|
803 | private fillErrorMessage;
|
804 | /**
|
805 | * Resolves a local file system URL
|
806 | * @param fileUrl {string} file system url
|
807 | * @returns {Promise<Entry>}
|
808 | */
|
809 | resolveLocalFilesystemUrl(fileUrl: string): Promise<Entry>;
|
810 | /**
|
811 | * Resolves a local directory url
|
812 | * @param directoryUrl {string} directory system url
|
813 | * @returns {Promise<DirectoryEntry>}
|
814 | */
|
815 | resolveDirectoryUrl(directoryUrl: string): Promise<DirectoryEntry>;
|
816 | /**
|
817 | * Get a directory
|
818 | * @param directoryEntry {DirectoryEntry} Directory entry, obtained by resolveDirectoryUrl method
|
819 | * @param directoryName {string} Directory name
|
820 | * @param flags {Flags} Options
|
821 | * @returns {Promise<DirectoryEntry>}
|
822 | */
|
823 | getDirectory(directoryEntry: DirectoryEntry, directoryName: string, flags: Flags): Promise<DirectoryEntry>;
|
824 | /**
|
825 | * Get a file
|
826 | * @param directoryEntry {DirectoryEntry} Directory entry, obtained by resolveDirectoryUrl method
|
827 | * @param fileName {string} File name
|
828 | * @param flags {Flags} Options
|
829 | * @returns {Promise<FileEntry>}
|
830 | */
|
831 | getFile(directoryEntry: DirectoryEntry, fileName: string, flags: Flags): Promise<FileEntry>;
|
832 | private readFile;
|
833 | /**
|
834 | * @hidden
|
835 | */
|
836 | private remove;
|
837 | /**
|
838 | * @hidden
|
839 | */
|
840 | private move;
|
841 | /**
|
842 | * @hidden
|
843 | */
|
844 | private copy;
|
845 | /**
|
846 | * @hidden
|
847 | */
|
848 | private readEntries;
|
849 | /**
|
850 | * @hidden
|
851 | */
|
852 | private rimraf;
|
853 | /**
|
854 | * @hidden
|
855 | */
|
856 | private createWriter;
|
857 | /**
|
858 | * @hidden
|
859 | */
|
860 | private write;
|
861 | /**
|
862 | * @hidden
|
863 | */
|
864 | private writeFileInChunks;
|
865 | }
|
866 |
|
867 | export declare const File: FileOriginal; |
\ | No newline at end of file |