3

Im using DexieJS for using IndexedDB - However, on IOS Safari, im sometimes getting the error: Error: indexedDB, error preparing Blob/File to be stored in object store

It's not consistently, which is pretty weird... Im trying to store "File Objects" in the database... It only seems to happen on IOS in Safari ?

An example of what im storing is this:

This is what im storing

Anyone experienced the same, and anyone know the solution?

The code for saving the entire thing:

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');
    }
});

};
nickycdk
  • 97
  • 1
  • 6

1 Answers1

0

Apple has fixed the bug, however, I still received error when saving a form with an empty file input. new FormData(myform) creates a file object for empty file inputs, and IOS indexedDB cannot handle the empty file shell.

Nathan Sutherland
  • 1,191
  • 7
  • 9