Skip to content

Commit

Permalink
fix(file): various fixes
Browse files Browse the repository at this point in the history
closes #1564
  • Loading branch information
ihadeed committed May 16, 2017
1 parent 7487293 commit d0dec7a
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion src/@ionic-native/plugins/file/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,37 @@ import { Injectable } from '@angular/core';
import { CordovaProperty, Plugin, CordovaCheck, 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;
name: string;
/**
* 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): void;
}

export interface LocalFileSystem {
Expand Down Expand Up @@ -85,6 +111,11 @@ export interface FileSystem {
* @readonly
*/
root: DirectoryEntry;

toJSON(): string;

encodeURIPath(path: string): string;

}

export interface Entry {
Expand All @@ -106,6 +137,14 @@ export interface Entry {
*/
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.
*/
Expand All @@ -121,6 +160,11 @@ export interface Entry {
*/
filesystem: FileSystem;

/**
* an alternate URL which can be used by native webview controls, for example media players.
*/
nativeURL: string;

/**
* Move an entry to a different location on the file system. It is an error to try to:
*
Expand Down Expand Up @@ -240,6 +284,8 @@ export interface DirectoryEntry extends Entry {
* </ul>
*/
export interface DirectoryReader {
localURL: string;
hasReadEntries: boolean;
/**
* Read the next block of entries from this directory.
* @param 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.
Expand Down Expand Up @@ -505,6 +551,7 @@ export declare class FileReader {
static EMPTY: number;
static LOADING: number;
static DONE: number;
static READ_CHUNK_SIZE: number;

readyState: number; // see constants in var declaration below
error: Error;
Expand Down Expand Up @@ -557,6 +604,12 @@ declare const window: Window;
* 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
* @interfaces
* IFile
* Entry
* DirectoryEntry
* DirectoryReader
* FileSystem
*/
@Plugin({
pluginName: 'File',
Expand Down

0 comments on commit d0dec7a

Please sign in to comment.