From 28dbc410b10c9d67cdd00f25a73083e58204ea01 Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Tue, 14 Oct 2014 14:47:52 +0000
Subject: [PATCH] use arraybuffer when fetching binary contents
---
humble_cloud/urkle_cloud.js | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/humble_cloud/urkle_cloud.js b/humble_cloud/urkle_cloud.js
index 427bccd..34e6afd 100644
--- a/humble_cloud/urkle_cloud.js
+++ b/humble_cloud/urkle_cloud.js
@@ -4,10 +4,10 @@
(function() {
// @todo: This may need adjusting to support fetching binary.
- function xhrGET(url, onload, onerror) {
+ function xhrGET(url, isBin, onload, onerror) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
- xhr.responseType = 'text';
+ xhr.responseType = isBin ? 'arraybuffer' : 'text';
xhr.onload = function () {
if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) {
onload(xhr.response);
@@ -54,7 +54,7 @@
var provider = {
vendor: 'Urkle!',
allFiles: function(options, onsuccess, onerror) {
- xhrGET(settings.remoteAPIEndpoint + '/storage/files?appToken=' + encodeURIComponent(options.applicationtoken), function(data) {
+ xhrGET(settings.remoteAPIEndpoint + '/storage/files?appToken=' + encodeURIComponent(options.applicationtoken), false, function(data) {
var json = JSON.parse(data),
ret = [];
ret = json.data.map(function(f) {
@@ -68,7 +68,7 @@
}, onerror);
},
read: function(options, url, onsuccess, onerror) {
- xhrGET(url, onsuccess, onerror);
+ xhrGET(url, true, onsuccess, onerror);
},
write: function(options, fileinfo, data, onsuccess, onerror) {
var q = 'appToken=' + encodeURIComponent(options.applicationtoken)
@@ -80,7 +80,7 @@
xhrDELETE(settings.remoteAPIEndpoint + '/storage/files/' + fileinfo.path, onsuccess, onerror);
},
isAvailable: function(options) {
- return false;
+ return true;
}
};
--
Gitblit v1.9.3