From 6743322bdd72c41ac0f7595ce8dd49fa1c6c5733 Mon Sep 17 00:00:00 2001 From: Hector Zarco Date: Thu, 26 Oct 2017 18:24:29 +1100 Subject: [PATCH] Expose addFiles method (#412) - Expose `addFiles` method that takes an array of File objects. --- README.md | 1 + resumable-tests.ts | 1 + resumable.d.ts | 4 ++++ resumable.js | 3 +++ 4 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 250335d3..5cce16fa 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ adding the file. (Default: `null`) * `.progress()` Returns a float between 0 and 1 indicating the current upload progress of all files. * `.isUploading()` Returns a boolean indicating whether or not the instance is currently uploading anything. * `.addFile(file)` Add a HTML5 File object to the list of files. +* `.addFiles(files)` Add an Array of HTML5 File objects to the list of files. * `.removeFile(file)` Cancel upload of a specific `ResumableFile` object on the list from the list. * `.getFromUniqueIdentifier(uniqueIdentifier)` Look up a `ResumableFile` object by its unique identifier. * `.getSize()` Returns the total size of the upload in bytes. diff --git a/resumable-tests.ts b/resumable-tests.ts index ea200695..6791fcf3 100644 --- a/resumable-tests.ts +++ b/resumable-tests.ts @@ -4,6 +4,7 @@ let resumable: Resumable = new Resumable({chunkSize: 123}); let resumableNoOpts: Resumable = new Resumable(); resumable.addFile(new File([], 'test.tmp'), {}); +resumable.addFiles([new File([], 'test.tmp')], {}); resumable.assignBrowse(document, true); resumable.assignBrowse([document], true); resumable.assignDrop(document); diff --git a/resumable.d.ts b/resumable.d.ts index cc4b32ca..6d6965db 100644 --- a/resumable.d.ts +++ b/resumable.d.ts @@ -208,6 +208,10 @@ declare module Resumable { * Add a HTML5 File object to the list of files. **/ addFile(file: File): void; + /** + * Add an Array of HTML5 File objects to the list of files. + **/ + addFiles(files: Array): void; /** * Cancel upload of a specific ResumableFile object on the list from the list. **/ diff --git a/resumable.js b/resumable.js index aaf20cd6..649e6a2a 100644 --- a/resumable.js +++ b/resumable.js @@ -1029,6 +1029,9 @@ $.addFile = function(file, event){ appendFilesFromFileList([file], event); }; + $.addFiles = function(files, event){ + appendFilesFromFileList(files, event); + }; $.removeFile = function(file){ for(var i = $.files.length - 1; i >= 0; i--) { if($.files[i] === file) {