diff --git a/package.json b/package.json index ca53196ca..93f9ff006 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "@angular/compiler": "4.1.2", "@angular/compiler-cli": "4.1.2", "@angular/core": "4.1.2", + "@types/cordova": "0.0.34", "canonical-path": "0.0.2", "child-process-promise": "2.2.0", "conventional-changelog-cli": "1.2.0", diff --git a/src/@ionic-native/plugins/file/index.ts b/src/@ionic-native/plugins/file/index.ts index 5d763a1d1..c0b5d8ba0 100644 --- a/src/@ionic-native/plugins/file/index.ts +++ b/src/@ionic-native/plugins/file/index.ts @@ -1,158 +1,346 @@ import { Injectable } from '@angular/core'; import { CordovaProperty, Plugin, CordovaCheck, IonicNativePlugin } from '@ionic-native/core'; -declare var window: any; -declare var cordova: any; - -/** This interface represents a file system. */ -export interface FileSystem { - /* The name of the file system, unique across the list of exposed file systems. */ +export interface IFile extends Blob { + lastModified: number; + lastModifiedDate: number; name: string; - /** The root directory of the file system. */ - root: DirectoryEntry; + size: number; + type: string; } -/** - * An abstract interface representing entries in a file system, - * each of which may be a File or DirectoryEntry. - */ -export interface Entry { - /** Entry is a file. */ - isFile: boolean; - /** Entry is a directory. */ - isDirectory: boolean; - /** 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; - nativeURL: string; +export interface LocalFileSystem { + /** - * Look up metadata about this entry. - * @param successCallback A callback that is called with the time of the last modification. - * @param errorCallback A callback that is called when errors happen. + * Used for storage with no guarantee of persistence. */ - getMetadata(successCallback: (metadata: Metadata) => void, - errorCallback?: (error: FileError) => void): void; + TEMPORARY: number; + /** - * 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. - * @param parent The directory to which to move the entry. - * @param newName The new name of the entry. Defaults to the Entry's current name if unspecified. - * @param successCallback A callback that is called with the Entry for the new location. - * @param errorCallback A callback that is called when errors happen. + * Used for storage that should not be removed by the user agent without application or user permission. */ - moveTo(parent: DirectoryEntry, - newName?: string, - successCallback?: (entry: Entry) => void, - errorCallback?: (error: FileError) => void): void; + PERSISTENT: number; + /** - * 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. - * @param parent The directory to which to move the entry. - * @param newName The new name of the entry. Defaults to the Entry's current name if unspecified. - * @param successCallback A callback that is called with the Entry for the new object. - * @param errorCallback A callback that is called when errors happen. + * 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. */ - copyTo(parent: DirectoryEntry, - newName?: string, - successCallback?: (entry: Entry) => void, - errorCallback?: (error: FileError) => void): void; + requestFileSystem(type: number, size: number, successCallback: FileSystemCallback, errorCallback?: ErrorCallback): void; + /** - * Returns a URL that can be used as the src attribute of a