import { IonicNativePlugin } from '@ionic-native/core'; export interface IFile extends Blob { /** * Name of the file, without path information */ name: string; /** * Last modified date */ lastModified: number; /** * Last modified date */ lastModifiedDate: number; /** * Size in bytes */ size: number; /** * File mime type */ type: string; localURL: string; start: number; end: number; /** * 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. * @param start {Number} The index at which to start the slice (inclusive). * @param end {Number} The index at which to end the slice (exclusive). */ slice(start: number, end: number): Blob; } export interface LocalFileSystem { /** * Used for storage with no guarantee of persistence. */ TEMPORARY: number; /** * Used for storage that should not be removed by the user agent without application or user permission. */ PERSISTENT: number; /** * Requests a filesystem in which to store application data. * @param type Whether the filesystem requested should be persistent, as defined above. Use one of TEMPORARY or * PERSISTENT. * @param size This is an indicator of how much storage space, in bytes, the application expects to need. * @param successCallback The callback that is called when the user agent provides a filesystem. * @param errorCallback A callback that is called when errors happen, or when the request to obtain the filesystem is * denied. */ requestFileSystem(type: number, size: number, successCallback: FileSystemCallback, errorCallback?: ErrorCallback): void; /** * Allows the user to look up the Entry for a file or directory referred to by a local URL. * @param url A URL referring to a local file in a filesystem accessable via this API. * @param successCallback A callback that is called to report the FileEntry to which the supplied URL refers. * @param errorCallback A callback that is called when errors happen, or when the request to obtain the Entry is * denied. */ resolveLocalFileSystemURL(url: string, successCallback: FileEntryCallback, errorCallback?: ErrorCallback): void; /** * see requestFileSystem. */ webkitRequestFileSystem(type: number, size: number, successCallback: FileSystemCallback, errorCallback?: ErrorCallback): void; } export interface Metadata { /** * This is the time at which the file or directory was last modified. * @readonly */ modificationTime: Date; /** * The size of the file, in bytes. This must return 0 for directories. * @readonly */ size: number; } export interface Flags { /** * Used to indicate that the user wants to create a file or directory if it was not previously there. */ create?: 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. */ exclusive?: boolean; } /** * This export interface represents a file system. */ export interface FileSystem { /** * 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. * @readonly */ name: string; /** * The root directory of the file system. * @readonly */ root: DirectoryEntry; toJSON(): string; encodeURIPath(path: string): string; } export interface Entry { /** * Entry is a file. */ isFile: boolean; /** * Entry is a directory. */ isDirectory: boolean; /** * Look up metadata about this entry. * @param successCallback A callback that is called with the time of the last modification. * @param errorCallback ErrorCallback A callback that is called when errors happen. */ getMetadata(successCallback: MetadataCallback, errorCallback?: ErrorCallback): void; /** * Set the metadata of the entry. * @param successCallback {Function} is called with a Metadata object * @param errorCallback {Function} is called with a FileError * @param metadataObject {Metadata} keys and values to set */ setMetadata(successCallback: MetadataCallback, errorCallback: ErrorCallback, metadataObject: Metadata): void; /** * The name of the entry, excluding the path leading to it. */ name: string; /** * The full absolute path from the root to the entry. */ fullPath: string; /** * The file system on which the entry resides. */ filesystem: FileSystem; /** * an alternate URL which can be used by native webview controls, for example media players. */ nativeURL: string; /** * Look up metadata about this entry. * @param successCallback A callback that is called with the time of the last modification. * @param errorCallback ErrorCallback A callback that is called when errors happen. */ getMetadata(successCallback: MetadataCallback, errorCallback?: ErrorCallback): void; /** * Set the metadata of the entry. * @param successCallback {Function} is called with a Metadata object * @param errorCallback {Function} is called with a FileError * @param metadataObject {Metadata} keys and values to set */ setMetadata(successCallback: MetadataCallback, errorCallback: ErrorCallback, metadataObject: Metadata): 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.
  • *