@ionic-native/file
- Version 5.36.0
- Published
- 340 kB
- 1 dependency
- MIT license
Install
npm i @ionic-native/file
yarn add @ionic-native/file
pnpm add @ionic-native/file
Overview
Ionic Native - Native plugins for ionic apps
Index
Variables
Classes
FileOriginal
- applicationDirectory
- applicationStorageDirectory
- cacheDirectory
- checkDir()
- checkFile()
- copyDir()
- copyFile()
- cordovaFileError
- createDir()
- createFile()
- dataDirectory
- documentsDirectory
- externalApplicationStorageDirectory
- externalCacheDirectory
- externalDataDirectory
- externalRootDirectory
- getDirectory()
- getFile()
- getFreeDiskSpace()
- listDir()
- moveDir()
- moveFile()
- readAsArrayBuffer()
- readAsBinaryString()
- readAsDataURL()
- readAsText()
- removeDir()
- removeFile()
- removeRecursively()
- resolveDirectoryUrl()
- resolveLocalFilesystemUrl()
- sharedDirectory
- syncedDataDirectory
- tempDirectory
- writeExistingFile()
- writeFile()
Interfaces
Type Aliases
Variables
variable File
const File: FileOriginal;
Classes
class FileError
class FileError {}
constructor
constructor(code: number);
property ABORT_ERR
static ABORT_ERR: number;
property code
code: number;
Error code
property ENCODING_ERR
static ENCODING_ERR: number;
property INVALID_MODIFICATION_ERR
static INVALID_MODIFICATION_ERR: number;
property INVALID_STATE_ERR
static INVALID_STATE_ERR: number;
property message
message: string;
property NO_MODIFICATION_ALLOWED_ERR
static NO_MODIFICATION_ALLOWED_ERR: number;
property NOT_FOUND_ERR
static NOT_FOUND_ERR: number;
property NOT_READABLE_ERR
static NOT_READABLE_ERR: number;
property PATH_EXISTS_ERR
static PATH_EXISTS_ERR: number;
property QUOTA_EXCEEDED_ERR
static QUOTA_EXCEEDED_ERR: number;
property SECURITY_ERR
static SECURITY_ERR: number;
property SYNTAX_ERR
static SYNTAX_ERR: number;
property TYPE_MISMATCH_ERR
static TYPE_MISMATCH_ERR: number;
class FileOriginal
class FileOriginal extends IonicNativePlugin {}
File filesystem This plugin implements a File API allowing read/write access to files residing on the device.
The File class implements static convenience functions to access files and directories.
Example:
import { File } from '@ionic-native/file/ngx';constructor(private file: File) { }...this.file.checkDir(this.file.dataDirectory, 'mydir').then(_ => console.log('Directory exists')).catch(err =>console.log('Directory doesn't exist'));This plugin is based on several specs, including : The HTML5 File API http: //www.w3.org/TR/FileAPI/ The (now-defunct) Directories and System extensions Latest: http: //www.w3.org/TR/2012/WD-file-system-api-20120417/ Although most of the plugin code was written when an earlier spec was current: http: //www.w3.org/TR/2011/WD-file-system-api-20110419/ It also implements the FileWriter spec : http: //dev.w3.org/2009/dap/file-system/file-writer.html IFile Entry DirectoryEntry DirectoryReader FileSystem
property applicationDirectory
applicationDirectory: string;
Read-only directory where the application is installed.
property applicationStorageDirectory
applicationStorageDirectory: string;
Read-only directory where the application is installed.
property cacheDirectory
cacheDirectory: string;
Cached files that should survive app restarts. Apps should not rely on the OS to delete files in here.
property cordovaFileError
cordovaFileError: any;
property dataDirectory
dataDirectory: string;
Where to put app-specific data files.
property documentsDirectory
documentsDirectory: string;
iOS: Files private to the app, but that are meaningful to other applications (e.g. Office files)
property externalApplicationStorageDirectory
externalApplicationStorageDirectory: string;
Android: the application space on external storage.
property externalCacheDirectory
externalCacheDirectory: string;
Android: the application cache on external storage.
property externalDataDirectory
externalDataDirectory: string;
Android: Where to put app-specific data files on external storage.
property externalRootDirectory
externalRootDirectory: string;
Android: the external storage (SD card) root.
property sharedDirectory
sharedDirectory: string;
BlackBerry10: Files globally available to all apps
property syncedDataDirectory
syncedDataDirectory: string;
iOS: Holds app-specific files that should be synced (e.g. to iCloud).
property tempDirectory
tempDirectory: string;
iOS: Temp directory that the OS can clear at will.
method checkDir
checkDir: (path: string, dir: string) => Promise<boolean>;
Check if a directory exists in a certain path, directory.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystem above
Parameter dir
Name of directory to check
Returns
{Promise} Returns a Promise that resolves to true if the directory exists or rejects with an error.
method checkFile
checkFile: (path: string, file: string) => Promise<boolean>;
Check if a file exists in a certain path, directory.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystem above
Parameter file
Name of file to check
Returns
{Promise} Returns a Promise that resolves with a boolean or rejects with an error.
method copyDir
copyDir: ( path: string, dirName: string, newPath: string, newDirName: string) => Promise<Entry>;
Copy a directory in various methods. If destination directory exists, will fail to copy.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystems above
Parameter dirName
Name of directory to copy
Parameter newPath
Base FileSystem of new location
Parameter newDirName
New name of directory to copy to (leave blank to remain the same)
Returns
{Promise} Returns a Promise that resolves to the new Entry object or rejects with an error.
method copyFile
copyFile: ( path: string, fileName: string, newPath: string, newFileName: string) => Promise<Entry>;
Copy a file in various methods. If file exists, will fail to copy.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystem above
Parameter fileName
Name of file to copy
Parameter newPath
Base FileSystem of new location
Parameter newFileName
New name of file to copy to (leave blank to remain the same)
Returns
{Promise} Returns a Promise that resolves to an Entry or rejects with an error.
method createDir
createDir: ( path: string, dirName: string, replace: boolean) => Promise<DirectoryEntry>;
Creates a new directory in the specific path. The replace boolean value determines whether to replace an existing directory with the same name. If an existing directory exists and the replace value is false, the promise will fail and return an error.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystem above
Parameter dirName
Name of directory to create
Parameter replace
If true, replaces file with same name. If false returns error
Returns
{Promise} Returns a Promise that resolves with a DirectoryEntry or rejects with an error.
method createFile
createFile: ( path: string, fileName: string, replace: boolean) => Promise<FileEntry>;
Creates a new file in the specific path. The replace boolean value determines whether to replace an existing file with the same name. If an existing file exists and the replace value is false, the promise will fail and return an error.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystem above
Parameter fileName
Name of file to create
Parameter replace
If true, replaces file with same name. If false returns error
Returns
{Promise} Returns a Promise that resolves to a FileEntry or rejects with an error.
method getDirectory
getDirectory: ( directoryEntry: DirectoryEntry, directoryName: string, flags: Flags) => Promise<DirectoryEntry>;
Get a directory
Parameter directoryEntry
Directory entry, obtained by resolveDirectoryUrl method
Parameter directoryName
Directory name
Parameter flags
Options
Returns
{Promise}
method getFile
getFile: ( directoryEntry: DirectoryEntry, fileName: string, flags: Flags) => Promise<FileEntry>;
Get a file
Parameter directoryEntry
Directory entry, obtained by resolveDirectoryUrl method
Parameter fileName
File name
Parameter flags
Options
Returns
{Promise}
method getFreeDiskSpace
getFreeDiskSpace: () => Promise<number>;
Get free disk space in Bytes
Returns
{Promise} Returns a promise that resolves with the remaining free disk space in Bytes
method listDir
listDir: (path: string, dirName: string) => Promise<Entry[]>;
List files and directory from a given path.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystems above
Parameter dirName
Name of directory
Returns
{Promise<Entry[]>} Returns a Promise that resolves to an array of Entry objects or rejects with an error.
method moveDir
moveDir: ( path: string, dirName: string, newPath: string, newDirName: string) => Promise<DirectoryEntry | Entry>;
Move a directory to a given path.
Parameter path
The source path to the directory
Parameter dirName
The source directory name
Parameter newPath
The destination path to the directory
Parameter newDirName
The destination directory name
Returns
{Promise<DirectoryEntry|Entry>} Returns a Promise that resolves to the new DirectoryEntry object or rejects with an error.
method moveFile
moveFile: ( path: string, fileName: string, newPath: string, newFileName: string) => Promise<Entry>;
Move a file to a given path.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystem above
Parameter fileName
Name of file to move
Parameter newPath
Base FileSystem of new location
Parameter newFileName
New name of file to move to (leave blank to remain the same)
Returns
{Promise} Returns a Promise that resolves to the new Entry or rejects with an error.
method readAsArrayBuffer
readAsArrayBuffer: (path: string, file: string) => Promise<ArrayBuffer>;
Read file and return data as an ArrayBuffer.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystem above
Parameter file
Name of file, relative to path.
Returns
{Promise} Returns a Promise that resolves with the contents of the file as ArrayBuffer or rejects with an error.
method readAsBinaryString
readAsBinaryString: (path: string, file: string) => Promise<string>;
Read file and return data as a binary data.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystem above
Parameter file
Name of file, relative to path.
Returns
{Promise} Returns a Promise that resolves with the contents of the file as string rejects with an error.
method readAsDataURL
readAsDataURL: (path: string, file: string) => Promise<string>;
Read file and return data as a base64 encoded data url. A data url is of the form: data: [][;base64],
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystem above
Parameter file
Name of file, relative to path.
Returns
{Promise} Returns a Promise that resolves with the contents of the file as data URL or rejects with an error.
method readAsText
readAsText: (path: string, file: string) => Promise<string>;
Read the contents of a file as text.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystem above
Parameter file
Name of file, relative to path.
Returns
{Promise} Returns a Promise that resolves with the contents of the file as string or rejects with an error.
method removeDir
removeDir: (path: string, dirName: string) => Promise<RemoveResult>;
Remove a directory at a given path.
Parameter path
The path to the directory
Parameter dirName
The directory name
Returns
{Promise} Returns a Promise that resolves to a RemoveResult or rejects with an error.
method removeFile
removeFile: (path: string, fileName: string) => Promise<RemoveResult>;
Removes a file from a desired location.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystem above
Parameter fileName
Name of file to remove
Returns
{Promise} Returns a Promise that resolves to a RemoveResult or rejects with an error.
method removeRecursively
removeRecursively: (path: string, dirName: string) => Promise<RemoveResult>;
Removes all files and the directory from a desired location.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystem above
Parameter dirName
Name of directory
Returns
{Promise} Returns a Promise that resolves with a RemoveResult or rejects with an error.
method resolveDirectoryUrl
resolveDirectoryUrl: (directoryUrl: string) => Promise<DirectoryEntry>;
Resolves a local directory url
Parameter directoryUrl
directory system url
Returns
{Promise}
method resolveLocalFilesystemUrl
resolveLocalFilesystemUrl: (fileUrl: string) => Promise<Entry>;
Resolves a local file system URL
Parameter fileUrl
file system url
Returns
{Promise}
method writeExistingFile
writeExistingFile: ( path: string, fileName: string, text: string | Blob) => Promise<void>;
Write to an existing file.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystem above
Parameter fileName
path relative to base path
Parameter text
content or blob to write
Returns
{Promise} Returns a Promise that resolves or rejects with an error.
method writeFile
writeFile: ( path: string, fileName: string, text: string | Blob | ArrayBuffer, options?: IWriteOptions) => Promise<any>;
Write a new file to the desired location.
Parameter path
Base FileSystem. Please refer to the iOS and Android filesystem above
Parameter fileName
path relative to base path
Parameter text
content, blob or ArrayBuffer to write
Parameter whether
to replace/append to an existing file. See IWriteOptions for more information.
Returns
{Promise} Returns a Promise that resolves to updated file entry or rejects with an error.
class FileReader
class FileReader {}
property DONE
static DONE: number;
property EMPTY
static EMPTY: number;
property error
error: Error;
property LOADING
static LOADING: number;
property onabort
onabort: (evt: ProgressEvent) => void;
property onerror
onerror: (evt: ProgressEvent) => void;
property onload
onload: (evt: ProgressEvent) => void;
property onloadend
onloadend: (evt: ProgressEvent) => void;
property onloadstart
onloadstart: (evt: ProgressEvent) => void;
property onprogress
onprogress: (evt: ProgressEvent) => void;
property READ_CHUNK_SIZE
static READ_CHUNK_SIZE: number;
property readyState
readyState: number;
property result
result: string | ArrayBuffer;
method abort
abort: () => void;
method readAsArrayBuffer
readAsArrayBuffer: (fe: IFile) => void;
method readAsBinaryString
readAsBinaryString: (fe: IFile) => void;
method readAsDataURL
readAsDataURL: (fe: IFile) => void;
method readAsText
readAsText: (fe: IFile, encoding?: string) => void;
class FileSaver
class FileSaver extends EventTarget {}
constructor
constructor(data: Blob);
When the FileSaver constructor is called, the user agent must return a new FileSaver object with readyState set to INIT. This constructor must be visible when the script's global object is either a Window object or an object implementing the WorkerUtils interface.
constructor
constructor(data: Blob);
When the FileSaver constructor is called, the user agent must return a new FileSaver object with readyState set to INIT. This constructor must be visible when the script's global object is either a Window object or an object implementing the WorkerUtils interface.
property DONE
DONE: number;
The entire Blob has been written to the file, an error occurred during the write, or the write was aborted using abort(). The FileSaver is no longer writing the blob.
Modifiers
@readonly
property error
error: Error;
The last error that occurred on the FileSaver.
Modifiers
@readonly
property INIT
INIT: number;
The blob is being written.
Modifiers
@readonly
property onabort
onabort: (event: ProgressEvent) => void;
Handler for abort events.
property onerror
onerror: (event: ProgressEvent) => void;
Handler for error events.
property onprogress
onprogress: (event: ProgressEvent) => void;
Handler for progress events.
property onwrite
onwrite: (event: ProgressEvent) => void;
Handler for write events.
property onwriteend
onwriteend: (event: ProgressEvent) => void;
Handler for write end events.
property onwritestart
onwritestart: (event: ProgressEvent) => void;
Handler for write start events
property readyState
readyState: number;
The FileSaver object can be in one of 3 states. The readyState attribute, on getting, must return the current state, which must be one of the following values: INIT WRITING DONE
Modifiers
@readonly
property WRITING
WRITING: number;
The object has been constructed, but there is no pending write.
Modifiers
@readonly
method abort
abort: { (): void; (): void };
When the abort method is called, user agents must run the steps below: If readyState == DONE or readyState == INIT, terminate this overall series of steps without doing anything else. Set readyState to DONE. If there are any tasks from the object's FileSaver task source in one of the task queues, then remove those tasks. Terminate the write algorithm being processed. Set the error attribute to a DOMError object of type "AbortError". Fire a progress event called abort Fire a progress event called write end Terminate this algorithm.
When the abort method is called, user agents must run the steps below: If readyState == DONE or readyState == INIT, terminate this overall series of steps without doing anything else. Set readyState to DONE. If there are any tasks from the object's FileSaver task source in one of the task queues, then remove those tasks. Terminate the write algorithm being processed. Set the error attribute to a DOMError object of type "AbortError". Fire a progress event called abort Fire a progress event called writeend Terminate this algorithm.
class FileWriter
class FileWriter extends FileSaver {}
This interface expands on the FileSaver interface to allow for multiple write actions, rather than just saving a single Blob.
property length
length: number;
The length of the file. If the user does not have read access to the file, this must be the highest byte offset at which the user has written.
property position
position: number;
The byte offset at which the next write to the file will occur. This must be no greater than length. A newly-created FileWriter must have position set to 0.
method seek
seek: (offset: number) => void;
Seek sets the file position at which the next write will occur.
Parameter offset
If nonnegative, an absolute byte offset into the file. If negative, an offset back from the end of the file.
method truncate
truncate: (size: number) => void;
Changes the length of the file to that specified. If shortening the file, data beyond the new length must be discarded. If extending the file, the existing data must be zero-padded up to the new length.
Parameter size
The size to which the length of the file is to be adjusted, measured in bytes.
method write
write: (data: ArrayBuffer | Blob | string) => void;
Write the supplied data to the file at position.
Parameter data
The blob to write.
Interfaces
interface DirectoryEntry
interface DirectoryEntry extends Entry {}
This export interface represents a directory on a file system.
method createReader
createReader: () => DirectoryReader;
Creates a new DirectoryReader to read Entries from this Directory.
method getDirectory
getDirectory: ( path: string, options?: Flags, successCallback?: DirectoryEntryCallback, errorCallback?: ErrorCallback) => void;
Creates or looks up a directory.
Parameter path
Either an absolute path or a relative path from this DirectoryEntry to the directory to be looked up or created. It is an error to attempt to create a directory whose immediate parent does not yet exist.
Parameter options
If create and exclusive are both true and the path already exists, getDirectory must fail. If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry. If create is not true and the path doesn't exist, getDirectory must fail. If create is not true and the path exists, but is a file, getDirectory must fail. Otherwise, if no other error occurs, getDirectory must return a DirectoryEntry corresponding to path.
Parameter successCallback
A callback that is called to return the DirectoryEntry selected or created.
Parameter errorCallback
A callback that is called when errors happen.
method getFile
getFile: ( path: string, options?: Flags, successCallback?: FileEntryCallback, errorCallback?: ErrorCallback) => void;
Creates or looks up a file.
Parameter path
Either an absolute path or a relative path from this DirectoryEntry to the file to be looked up or created. It is an error to attempt to create a file whose immediate parent does not yet exist.
Parameter options
If create and exclusive are both true, and the path already exists, getFile must fail. If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry. If create is not true and the path doesn't exist, getFile must fail. If create is not true and the path exists, but is a directory, getFile must fail. Otherwise, if no other error occurs, getFile must return a FileEntry corresponding to path.
Parameter successCallback
A callback that is called to return the File selected or created.
Parameter errorCallback
A callback that is called when errors happen.
method removeRecursively
removeRecursively: ( successCallback: VoidCallback, errorCallback?: ErrorCallback) => void;
Deletes a directory and all of its contents, if any. In the event of an error [e.g. trying to delete a directory that contains a file that cannot be removed], some of the contents of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem.
Parameter successCallback
A callback that is called on success.
Parameter errorCallback
A callback that is called when errors happen.
interface DirectoryReader
interface DirectoryReader {}
This export interface lets a user list files and directories in a directory. If there are no additions to or deletions from a directory between the first and last call to readEntries, and no errors occur, then: A series of calls to readEntries must return each entry in the directory exactly once. Once all entries have been returned, the next call to readEntries must produce an empty array. If not all entries have been returned, the array produced by readEntries must not be empty. The entries produced by readEntries must not include the directory itself ["."] or its parent [".."].
property hasReadEntries
hasReadEntries: boolean;
property localURL
localURL: string;
method readEntries
readEntries: ( successCallback: EntriesCallback, errorCallback?: ErrorCallback) => void;
Read the next block of entries from this directory.
Parameter successCallback
Called once per successful call to readEntries to deliver the next previously-unreported set of Entries in the associated Directory. If all Entries have already been returned from previous invocations of readEntries, successCallback must be called with a zero-length array as an argument.
Parameter errorCallback
A callback indicating that there was an error reading from the Directory.
interface Entry
interface Entry {}
property filesystem
filesystem: FileSystem;
The file system on which the entry resides.
property fullPath
fullPath: string;
The full absolute path from the root to the entry.
property isDirectory
isDirectory: boolean;
Entry is a directory.
property isFile
isFile: boolean;
Entry is a file.
property name
name: string;
The name of the entry, excluding the path leading to it.
property nativeURL
nativeURL: string;
an alternate URL which can be used by native webview controls, for example media players.
method copyTo
copyTo: ( parent: DirectoryEntry, newName?: string, successCallback?: EntryCallback, errorCallback?: ErrorCallback) => void;
Copy an entry to a different location on the file system. It is an error to try to:
copy a directory inside itself or to any child at any depth; copy an entry into its parent if a name different from its current one isn't provided; copy a file to a path occupied by a directory; copy a directory to a path occupied by a file; copy any element to a path occupied by a directory which is not empty. A copy of a file on top of an existing file must attempt to delete and replace that file. A copy of a directory on top of an existing empty directory must attempt to delete and replace that directory.
Directory copies are always recursive--that is, they copy all contents of the directory.
method getMetadata
getMetadata: { (successCallback: MetadataCallback, errorCallback?: ErrorCallback): void; (successCallback: MetadataCallback, errorCallback?: ErrorCallback): void;};
Look up metadata about this entry.
Parameter successCallback
A callback that is called with the time of the last modification.
Parameter errorCallback
ErrorCallback A callback that is called when errors happen.
method getParent
getParent: ( successCallback: DirectoryEntryCallback, errorCallback?: ErrorCallback) => void;
Look up the parent DirectoryEntry containing this Entry. If this Entry is the root of its filesystem, its parent is itself.
Parameter successCallback
A callback that is called to return the parent Entry.
Parameter errorCallback
A callback that is called when errors happen.
method moveTo
moveTo: ( parent: DirectoryEntry, newName?: string, successCallback?: EntryCallback, errorCallback?: ErrorCallback) => void;
Move an entry to a different location on the file system. It is an error to try to:
move a directory inside itself or to any child at any depth; move an entry into its parent if a name different from its current one isn't provided; move a file to a path occupied by a directory; move a directory to a path occupied by a file; move any element to a path occupied by a directory which is not empty.
A move of a file on top of an existing file must attempt to delete and replace that file. A move of a directory on top of an existing empty directory must attempt to delete and replace that directory.
method remove
remove: (successCallback: VoidCallback, errorCallback?: ErrorCallback) => void;
Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to attempt to delete the root directory of a filesystem.
Parameter successCallback
A callback that is called on success.
Parameter errorCallback
A callback that is called when errors happen.
method setMetadata
setMetadata: { ( successCallback: MetadataCallback, errorCallback: ErrorCallback, metadataObject: Metadata ): void; ( successCallback: MetadataCallback, errorCallback: ErrorCallback, metadataObject: Metadata ): void;};
Set the metadata of the entry.
Parameter successCallback
is called with a Metadata object
Parameter errorCallback
is called with a FileError
Parameter metadataObject
keys and values to set
method toInternalURL
toInternalURL: () => string;
Return a URL that can be passed across the bridge to identify this entry. string URL that can be passed across the bridge to identify this entry
method toURL
toURL: () => string;
Returns a URL that can be used to identify this entry. Unlike the URN defined in [FILE-API-ED], it has no specific expiration; as it describes a location on disk, it should be valid at least as long as that location exists.
interface FileEntry
interface FileEntry extends Entry {}
This export interface represents a file on a file system.
method createWriter
createWriter: ( successCallback: FileWriterCallback, errorCallback?: ErrorCallback) => void;
Creates a new FileWriter associated with the file that this FileEntry represents.
Parameter successCallback
A callback that is called with the new FileWriter.
Parameter errorCallback
A callback that is called when errors happen.
method file
file: (successCallback: FileCallback, errorCallback?: ErrorCallback) => void;
Returns a File that represents the current state of the file that this FileEntry represents.
Parameter successCallback
A callback that is called with the File.
Parameter errorCallback
A callback that is called when errors happen.
interface FileSystem
interface FileSystem {}
This export interface represents a file system.
property name
name: string;
This is the name of the file system. The specifics of naming filesystems is unspecified, but a name must be unique across the list of exposed file systems.
Modifiers
@readonly
property root
root: DirectoryEntry;
The root directory of the file system.
Modifiers
@readonly
method encodeURIPath
encodeURIPath: (path: string) => string;
method toJSON
toJSON: () => string;
interface Flags
interface Flags {}
property create
create?: boolean;
Used to indicate that the user wants to create a file or directory if it was not previously there.
property exclusive
exclusive?: boolean;
By itself, exclusive must have no effect. Used with create, it must cause getFile and getDirectory to fail if the target path already exists.
interface IFile
interface IFile extends Blob {}
property end
end: number;
property lastModified
lastModified: number;
Last modified date
property lastModifiedDate
lastModifiedDate: number;
Last modified date
property localURL
localURL: string;
property name
name: string;
Name of the file, without path information
property size
size: number;
Size in bytes
property start
start: number;
property type
type: string;
File mime type
method slice
slice: (start: number, end: number) => Blob;
Returns a "slice" of the file. Since Cordova Files don't contain the actual content, this really returns a File with adjusted start and end. Slices of slices are supported.
Parameter start
The index at which to start the slice (inclusive).
Parameter end
The index at which to end the slice (exclusive).
interface IWriteOptions
interface IWriteOptions {}
interface LocalFileSystem
interface LocalFileSystem {}
property PERSISTENT
PERSISTENT: number;
Used for storage that should not be removed by the user agent without application or user permission.
property TEMPORARY
TEMPORARY: number;
Used for storage with no guarantee of persistence.
method requestFileSystem
requestFileSystem: ( type: number, size: number, successCallback: FileSystemCallback, errorCallback?: ErrorCallback) => void;
Requests a filesystem in which to store application data.
Parameter type
Whether the filesystem requested should be persistent, as defined above. Use one of TEMPORARY or PERSISTENT.
Parameter size
This is an indicator of how much storage space, in bytes, the application expects to need.
Parameter successCallback
The callback that is called when the user agent provides a filesystem.
Parameter errorCallback
A callback that is called when errors happen, or when the request to obtain the filesystem is denied.
method resolveLocalFileSystemURL
resolveLocalFileSystemURL: ( url: string, successCallback: FileEntryCallback, errorCallback?: ErrorCallback) => void;
Allows the user to look up the Entry for a file or directory referred to by a local URL.
Parameter url
A URL referring to a local file in a filesystem accessable via this API.
Parameter successCallback
A callback that is called to report the FileEntry to which the supplied URL refers.
Parameter errorCallback
A callback that is called when errors happen, or when the request to obtain the Entry is denied.
method webkitRequestFileSystem
webkitRequestFileSystem: ( type: number, size: number, successCallback: FileSystemCallback, errorCallback?: ErrorCallback) => void;
see requestFileSystem.
interface Metadata
interface Metadata {}
property modificationTime
modificationTime: Date;
This is the time at which the file or directory was last modified.
Modifiers
@readonly
property size
size: number;
The size of the file, in bytes. This must return 0 for directories.
Modifiers
@readonly
interface RemoveResult
interface RemoveResult {}
property fileRemoved
fileRemoved: Entry;
property success
success: boolean;
Type Aliases
type DirectoryEntryCallback
type DirectoryEntryCallback = (entry: DirectoryEntry) => void;
This export interface is the callback used to look up DirectoryEntry objects.
type EntriesCallback
type EntriesCallback = (entries: Entry[]) => void;
When readEntries() succeeds, the following callback is made.
type EntryCallback
type EntryCallback = (entry: Entry) => void;
This export interface is the callback used to look up Entry objects.
type ErrorCallback
type ErrorCallback = (err: FileError) => void;
When an error occurs, the following callback is made.
type FileCallback
type FileCallback = (file: IFile) => void;
This export interface is the callback used to obtain a File.
type FileEntryCallback
type FileEntryCallback = (entry: FileEntry) => void;
This export interface is the callback used to look up FileEntry objects.
type FileSystemCallback
type FileSystemCallback = (filesystem: FileSystem) => void;
When requestFileSystem() succeeds, the following callback is made.
type FileWriterCallback
type FileWriterCallback = (fileWriter: FileWriter) => void;
This export interface is the callback used to create a FileWriter.
type MetadataCallback
type MetadataCallback = (metadata: Metadata) => void;
This export interface is the callback used to look up file and directory metadata.
type VoidCallback
type VoidCallback = () => void;
This export interface is the generic callback used to indicate success of an asynchronous method.
Package Files (1)
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (2)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@ionic-native/file
.
- Markdown[](https://www.jsdocs.io/package/@ionic-native/file)
- HTML<a href="https://www.jsdocs.io/package/@ionic-native/file"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3493 ms. - Missing or incorrect documentation? Open an issue for this package.