You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2013/06/15 06:38:47 UTC
js commit: [CB-2406] Guard against lack of Blob/ArrayBuffer support
in Android pre-3.0
Updated Branches:
refs/heads/master 919f819cb -> f532b845b
[CB-2406] Guard against lack of Blob/ArrayBuffer support in Android pre-3.0
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/f532b845
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/f532b845
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/f532b845
Branch: refs/heads/master
Commit: f532b845bab2c112ec246d293cd54f9d4d708b3c
Parents: 919f819
Author: Ian Clelland <ic...@chromium.org>
Authored: Sat Jun 15 00:38:13 2013 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Sat Jun 15 00:38:13 2013 -0400
----------------------------------------------------------------------
lib/common/plugin/FileWriter.js | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f532b845/lib/common/plugin/FileWriter.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/FileWriter.js b/lib/common/plugin/FileWriter.js
index e9930ab..98ee8d6 100644
--- a/lib/common/plugin/FileWriter.js
+++ b/lib/common/plugin/FileWriter.js
@@ -97,21 +97,27 @@ FileWriter.prototype.abort = function() {
*/
FileWriter.prototype.write = function(data) {
- // Check to see if the incoming data is a blob
- if (data instanceof Blob) {
- var that=this;
- var fileReader = new FileReader();
- fileReader.onload = function() {
- // Call this method again, with the arraybuffer as argument
- FileWriter.prototype.write.call(that, this.result);
- };
- fileReader.readAsArrayBuffer(data);
- return;
+ var isBinary = false;
+
+ // If we don't have Blob or ArrayBuffer support, don't bother.
+ if (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined') {
+
+ // Check to see if the incoming data is a blob
+ if (data instanceof Blob) {
+ var that=this;
+ var fileReader = new FileReader();
+ fileReader.onload = function() {
+ // Call this method again, with the arraybuffer as argument
+ FileWriter.prototype.write.call(that, this.result);
+ };
+ fileReader.readAsArrayBuffer(data);
+ return;
+ }
+
+ // Mark data type for safer transport over the binary bridge
+ isBinary = (data instanceof ArrayBuffer);
}
- // Mark data type for safer transport over the binary bridge
- var isBinary = (data instanceof ArrayBuffer);
-
// Throw an exception if we are already writing a file
if (this.readyState === FileWriter.WRITING) {
throw new FileError(FileError.INVALID_STATE_ERR);