Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Feature/1711 remove file ref method #1737

Merged
merged 2 commits into from
Jan 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client/js/uploader.basic.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@
return false;
},

removeFileRef: function(id) {
this._handler.expunge(id);
},

reset: function() {
this.log("Resetting uploader...");

Expand Down
2 changes: 1 addition & 1 deletion client/js/version.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/*global qq */
qq.version = "5.12.0";
qq.version = "5.14.0-beta1";
14 changes: 14 additions & 0 deletions docs/api/methods.jmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ $(document).ready(function() {
{% markdown %}
## Core
{% endmarkdown %}

{{
alert("If you pass a large `Blob` that was created using JavaScript in the browser into `addFiles`, you should consider calling the [`removeFileRef` method](#removeFileRef) after the file has been successfully uploaded to free up any memory consumed by the Blob.")
}}

{{ api_method("addFiles", "addFiles (files[, params[, endpoint]])", "Submit one or more files to the uploader.

A `BlobWrapper` object:
Expand Down Expand Up @@ -352,6 +357,15 @@ A `resizeInfo` object, which will be passed to the supplied function, contains t

]) }}

{{ api_method("removeFileRef", "removeFileRef (id)", "",
[
{
"name": "id",
"type": "Integer",
"description": "Remove internal reference to the associated Blob/File object. For Blobs that are created via JavaScript in the browser, this will free up all consumed memory."
}
]) }}

{{ api_method("reset", "reset ()", "Reset Fine Uploader", null, null) }}

{{ api_method("retry", "retry (id)", "Attempt to upload a specific item again.",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "fine-uploader",
"title": "Fine Uploader",
"main": "lib/traditional.js",
"version": "5.13.0",
"version": "5.14.0-beta1",
"description": "Multiple file upload plugin with progress-bar, drag-and-drop, direct-to-S3 & Azure uploading, client-side image scaling, preview generation, form support, chunking, auto-resume, and tons of other features.",
"keywords": [
"amazon",
Expand Down
25 changes: 25 additions & 0 deletions test/unit/simple-file-uploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,5 +478,30 @@ if (qqtest.canDownloadFileAsBlob) {
uploader.addFiles(canvasWrapper);
});
});

it("removes reference to a Blob via API", function(done) {
qqtest.downloadFileAsBlob("up.jpg", "image/jpeg").then(function(blob) {
fileTestHelper.mockXhr();

var request,
uploader = new qq.FineUploaderBasic({
autoUpload: false,
request: { endpoint: testUploadEndpoint },
callbacks: {
onComplete: function(id) {
assert.ok(uploader.getFile(id));
uploader.removeFileRef(id);
assert.ok(!uploader.getFile(id));
done();
}
}
});

uploader.addFiles({name: "test", blob: blob});
uploader.uploadStoredFiles();

fileTestHelper.getRequests()[0].respond(200, null, JSON.stringify({success: true}));
});
});
});
}