From f22874342a75779c7569e5615308142abeed4dac Mon Sep 17 00:00:00 2001 From: Michael Nishikawa Date: Thu, 23 Feb 2017 20:56:26 -0300 Subject: [PATCH] refactor(file): accept ArrayBuffer for data to write (#1109) --- src/plugins/file.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/file.ts b/src/plugins/file.ts index 27837056b..1c5f5ca79 100644 --- a/src/plugins/file.ts +++ b/src/plugins/file.ts @@ -267,7 +267,7 @@ export interface FileWriter extends FileSaver { * Write the supplied data to the file at position. * @param {Blob} data The blob to write. */ - write(data: Blob | string): void; + write(data: ArrayBuffer | Blob | string): void; /** * The file position at which the next write will occur. * @param offset If nonnegative, an absolute byte offset into the file. @@ -671,7 +671,7 @@ export class File { * @returns {Promise} Returns a Promise that resolves to updated file entry or rejects with an error. */ static writeFile(path: string, fileName: string, - text: string | Blob, options: WriteOptions = {}): Promise { + text: string | Blob | ArrayBuffer, options: WriteOptions = {}): Promise { if ((/^\//.test(fileName))) { const err = new FileError(5); err.message = 'file-name cannot start with \/'; @@ -700,7 +700,7 @@ export class File { * @param {WriteOptions} options replace file if set to true. See WriteOptions for more information. * @returns {Promise} Returns a Promise that resolves to updated file entry or rejects with an error. */ - private static writeFileEntry(fe: FileEntry, text: string | Blob, options: WriteOptions) { + private static writeFileEntry(fe: FileEntry, text: string | Blob | ArrayBuffer, options: WriteOptions) { return File.createWriter(fe) .then((writer) => { if (options.append) { @@ -1133,7 +1133,7 @@ export class File { /** * @private */ - private static write(writer: FileWriter, gu: string | Blob): Promise { + private static write(writer: FileWriter, gu: string | Blob | ArrayBuffer): Promise { if (gu instanceof Blob) { return this.writeFileInChunks(writer, gu); }