gpt4 book ai didi

javascript - 错误 : indexedDB, 准备将 Blob/文件存储在对象存储中时出错

转载 作者:行者123 更新时间:2023-12-05 07:16:41 25 4
gpt4 key购买 nike

我使用 DexieJS 来使用 IndexedDB - 但是,在 IOS Safari 上,我有时会收到错误:错误:indexedDB,准备将 Blob/文件存储在对象存储中时出错

它不是始终如一的,这很奇怪......我试图在数据库中存储“文件对象”......它似乎只发生在 Safari 的 IOS 上?

我存储的一个例子是:

This is what im storing

谁有过同样的经历,谁知道解决办法?

保存整个东西的代码:

savePendingSurvey = (id, currentSurvey, surveyAnswers, surveyFiles) => {
deletePendingSurveyByID(id);

const updatedSurvey = {
id: id,
createdAt: new Date(),
status: 'UNSUBMITTED',
surveyVersion: currentSurvey.survey.version,
currentSurvey: currentSurvey.survey,
currentSurveyAnswers: surveyAnswers,
currentSurveyFiles: surveyFiles
};

console.log(updatedSurvey);

db.pendingSurveys.add(updatedSurvey).then((response) => {
console.info('done adding pending survey', response);
}).catch('InvalidStateError', e => {
// Failed with InvalidStateError
alert('InvalidState error:' + e.message);
}).catch(Error, e => {
// Any other error derived from standard Error
alert('Error saving survey: ' + e.message);
}).catch(e => {
// Other error such as a string was thrown
alert(e);
}).catch((e) => {
if ((e.name === 'QuotaExceededError') ||
(e.inner && e.inner.name === 'QuotaExceededError')) {
// QuotaExceededError may occur as the inner error of an AbortError
alert('Quota exceeded error! - It seems there are not enough space available on your device for us to save the survey');
} else {
// Any other error
alert('Cant save your survey: ' + e + ' - ' + e.inner.name + ' - Please try closing the app and clear your cache, and try again');
}
});

};

最佳答案

Apple 已修复此错误,但是,在保存包含空文件输入的表单时,我仍然收到错误消息。new FormData(myform) 为空文件输入创建一个文件对象,IOS indexedDB 无法处理空文件外壳。

关于javascript - 错误 : indexedDB, 准备将 Blob/文件存储在对象存储中时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59138045/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com