[
https://issues.apache.org/jira/browse/CB-7862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15186230#comment-15186230
]
ASF GitHub Bot commented on CB-7862:
------------------------------------
Github user riknoll commented on a diff in the pull request:
https://github.com/apache/cordova-plugin-file/pull/168#discussion_r55457515
--- Diff: www/FileReader.js ---
@@ -96,6 +106,78 @@ function initRead(reader, file) {
}
/**
+ * Callback used by the following read* functions to handle incremental or
final success.
+ * Must be bound to the FileReader's this along with all but the last
parameter,
+ * e.g. readSuccessCallback.bind(this, "readAsText", "UTF-8", offset,
totalSize, accumulate)
+ * @param readType The name of the read function to call.
+ * @param encoding Text encoding, or null if this is not a text type read.
+ * @param offset Starting offset of the read.
+ * @param totalSize Total number of bytes or chars to read.
+ * @param accumulate A function that takes the callback result and
accumulates it in this._result.
+ * @param r Callback result returned by the last read exec() call, or null
to begin reading.
+ */
+function readSuccessCallback(readType, encoding, offset, totalSize,
accumulate, r) {
+ if (this._readyState === FileReader.DONE) {
+ return;
+ }
+
+ if (typeof r !== "undefined") {
+ accumulate(r);
+ this._progress = Math.min(this._progress +
FileReader.READ_CHUNK_SIZE, totalSize);
+
+ if (typeof this.onprogress === "function") {
+ this.onprogress(new ProgressEvent("progress",
{loaded:this._progress, total:totalSize}));
+ }
+ }
+
+ if (typeof r === "undefined" || this._progress < totalSize) {
+ var execArgs = [
+ this._localURL,
+ offset + this._progress,
+ offset + this._progress + Math.min(totalSize - this._progress,
FileReader.READ_CHUNK_SIZE)];
+ if (encoding) {
--- End diff --
Sure, that works. I just thought it was unclear why you were inserting an
argument in this way
> FileReader reads large files in a single chunk causing OOM exceptions
> ---------------------------------------------------------------------
>
> Key: CB-7862
> URL: https://issues.apache.org/jira/browse/CB-7862
> Project: Apache Cordova
> Issue Type: Bug
> Components: Plugin File
> Affects Versions: 4.0.0
> Environment: Android
> Reporter: shenzhuxi
> Assignee: Jason Ginchereau
> Priority: Critical
>
> In Android, I tried to copy a 14MB file from html file input with
> org.apache.cordova.file 1.3.1. The App crashed and a 0 byte file was copied.
> I use http://ngcordova.com/ and here is my code
> https://github.com/shenzhuxi/readiator/blob/master/src/js/cordova-index.js.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]