fix: Fixed issue where files would not download correctly on mobile if they had special characters in the name

This commit is contained in:
Aman Harwara
2023-07-10 20:27:52 +05:30
parent 5c87f3a3b4
commit de6994f743
2 changed files with 12 additions and 1 deletions

View File

@@ -1,7 +1,9 @@
import { WebApplication } from '@/Application/WebApplication'
import { getBase64FromBlob } from '@/Utils'
import { parseFileName } from '@standardnotes/filepicker'
import { Platform } from '@standardnotes/snjs'
import { addToast, ToastType, dismissToast } from '@standardnotes/toast'
import { sanitizeFileName } from '@standardnotes/ui-services'
export const downloadBlobOnAndroid = async (
application: WebApplication,
@@ -20,6 +22,9 @@ export const downloadBlobOnAndroid = async (
})
}
const base64 = await getBase64FromBlob(blob)
const { name, ext } = parseFileName(filename)
const sanitizedName = sanitizeFileName(name)
filename = `${sanitizedName}.${ext}`
const downloaded = await application.mobileDevice().downloadBase64AsFile(base64, filename)
if (loadingToastId) {
dismissToast(loadingToastId)