From 4bfac53c9a77a3af35d029757eece53f4b7212ed Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 8 Feb 2012 13:11:48 -0800 Subject: Fixed data type issue on copying library files Fixed the methods to allow for ArrayBuffer data to be sent, fixes saving files that are not plain text. --- js/io/system/ninjalibrary.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'js/io/system/ninjalibrary.js') diff --git a/js/io/system/ninjalibrary.js b/js/io/system/ninjalibrary.js index 3914ec29..7b524189 100644 --- a/js/io/system/ninjalibrary.js +++ b/js/io/system/ninjalibrary.js @@ -114,8 +114,18 @@ exports.NinjaLibrary = Montage.create(Object.prototype, { //File to copy this.chromeApi.fileContent(contents[i].fullPath, function (result) { // - this.coreApi.createFile({uri: fileRoot+result.file.fullPath, contents: result.content, contentType: result.data.type}); - //this.coreApi.createFile({uri: fileRoot+result.file.fullPath, contents: result.content}); + + /* +var ui8a = new Uint8Array(result.content); + console.log(ui8a); + + var blob = new window.WebKitBlobBuilder; + blob.append(result.content); +*/ + //console.log(blob.getBlob(result.data.type)); + //this.coreApi.createFile({uri: fileRoot+result.file.fullPath, contents: result.content, contentType: result.data.type}); + //this.coreApi.createFile({uri: fileRoot+result.file.fullPath, contents: blob.getBlob(result.data.type), contentType: result.data.type}); + this.coreApi.createFile({uri: fileRoot+result.file.fullPath, contents: result.content}); }.bind(this)); } } @@ -187,11 +197,12 @@ exports.NinjaLibrary = Montage.create(Object.prototype, { //Getting file contents xhr = new XMLHttpRequest(); xhr.open("GET", tocopylibs[i].path, false); + xhr.responseType = "arraybuffer"; xhr.send(); //Checking for status if (xhr.readyState === 4) { //TODO: add check for mime type //Creating new file from loaded content - //this.chromeApi.fileNew('/'+tocopylibs[i].name+'/'+tocopylibs[i].file, xhr.response, function (status) {if(status) this.libraryCopied()}.bind(this)); + this.chromeApi.fileNew('/'+tocopylibs[i].name+'/'+tocopylibs[i].file, xhr.response, function (status) {if(status) this.libraryCopied()}.bind(this)); } else { //Error creating single file library } @@ -225,6 +236,7 @@ exports.NinjaLibrary = Montage.create(Object.prototype, { for (i=0; this.files[i]; i++) { xhr = new XMLHttpRequest(); xhr.open("GET", this.root+this.files[i], false); + xhr.responseType = "arraybuffer"; xhr.send(); //Checking for status if (xhr.readyState === 4) { -- cgit v1.2.3