Fix GalleryStorageService

GalleryStorageService is sending JSON so it couldn't serialize the
ArrayBuffer which came from serializing the Piskel. In this commit it
sends the ArrayBuffer as an Array to the server so it can store it easily.
This commit is contained in:
Dávid Szabó 2016-09-04 00:07:53 +02:00 committed by Julian Descottes
parent baf8049ea6
commit 5577c3ab5a
2 changed files with 4 additions and 4 deletions

View File

@ -12,7 +12,7 @@
var deferred = Q.defer();
var data = {
framesheet : this.piskelController.serialize(),
framesheet : '[' + new Uint8Array(this.piskelController.serialize()) + ']',
fps : this.piskelController.getFPS(),
name : descriptor.name,
description : descriptor.description,

View File

@ -10,7 +10,7 @@
var modelVersion;
var isJSON = false;
if (data instanceof ArrayBuffer) {
if (data instanceof ArrayBuffer || data instanceof Array) {
var uint8 = new Uint8Array(data);
// Backward compatibility for JSON (modelVersion < 3)
@ -22,7 +22,7 @@
data = JSON.parse(data);
modelVersion = data.modelVersion;
} else {
var arr16 = new Uint16Array(data);
var arr16 = new Uint16Array(uint8.buffer);
modelVersion = arr16[0];
}
} else {
@ -47,7 +47,7 @@
var j;
var buffer = this.data_;
var arr8 = new Uint8Array(buffer);
var arr16 = new Uint16Array(buffer);
var arr16 = new Uint16Array(arr8.buffer);
var sub;
/********/