c74dbbb68a
* Move into getLocalStorageSummary + always log - Move into getLocalStorageSummary to clean up the clutter. - Always log the localStorage info to get a bigger picture of what's going on with the QuotaExceededError. * Remove 'findPreviousUploads' - we use the url stored in Redux. Something I forgot to remove in the past. It also reads from localStorage, so remove since we are trying to avoid touching localStorage. * Ensure localStorage is not used when uploading I don't think it's being written when `storeFingerprintForResuming` is disabled, but doing the suggestion nonetheless. `https://github.com/tus/tus-js-client/issues/315#issuecomment-1046821112`
25 lines
541 B
JavaScript
25 lines
541 B
JavaScript
export function isLocalStorageAvailable() {
|
|
try {
|
|
return Boolean(window.localStorage);
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function isSessionStorageAvailable() {
|
|
try {
|
|
return Boolean(window.sessionStorage);
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function getLocalStorageSummary() {
|
|
try {
|
|
const count = window.localStorage.length;
|
|
const estimatedSize = JSON.stringify(window.localStorage).length;
|
|
return `${count} items; ${estimatedSize} bytes`;
|
|
} catch (e) {
|
|
return 'inaccessible';
|
|
}
|
|
}
|