2
當我嘗試存儲一個blob(通過XMLHttpRequest
GET
請求檢索,Safari瀏覽器在iOS 8.4引發錯誤:嘗試存儲BLOB在iOS的Safari瀏覽器8投DataCloneError
DataCloneError: DOM IDBDatabase Exception 25: The data being stored could
not be cloned by the internal structured cloning algorithm
這正好與我的代碼,同時也下面這個例子:http://robnyman.github.io/html5demos/indexeddb/
這是導致我的代碼(和上面的例子)失敗行:
//This throws the error
var put = transaction.objectStore("elephants").put(blob, "image");
是否有一個修復 爲了這? blob是否需要首先進行base64編碼(就像你必須使用WebSQL一樣)?
我的代碼(在桌面版Chrome/Firefox和Chrome/Firefox的Android上的作品):
var xhr = new XMLHttpRequest();
var blob;
//Get the Video
xhr.open("GET", "test.mp4", true);
//Set as blob
xhr.responseType = "blob";
//Listen for blob
xhr.addEventListener("load", function() {
if (xhr.status === 200) {
blob = xhr.response;
//Start transaction
var transaction = db.transaction(["Videos"], "readwrite");
//IT FAILS HERE
var put = transaction.objectStore("Videos").put(blob, "savedvideo");
}
else {
console.log("ERROR: Unable to download video.");
}
}, false);
xhr.send();
感謝您抽出時間將此記入此記錄。你遇到過任何其他應該鏈接到這裏的StackOverflow問題嗎?或者在其他StackExchange網站發佈問題? – sideshowbarker
另外,你知道這是否有一個開放的Safari/WebKit https://bugs.webkit.org/錯誤?如果沒有,請考慮舉一個。不管(如果已經有一個開放的,或者如果你打開一個),也可以鏈接到這裏。 – sideshowbarker
@sideshowbarker我確實在Apple的bug數據庫上創建了一個bug,而不是webkit,它不是一個WebKit問題(在關閉WebKit之前在Chrome中工作)這是Safari的實現,這是錯誤的。我發現其他一些老問題可能會遇到同樣的問題(不知道他們的代碼是不存在的),但沒有答案。 –