fix: Fixed issue where files would not download correctly on mobile if they had special characters in the name
This commit is contained in:
@@ -8,6 +8,8 @@ import ImagePreview from './ImagePreview'
|
||||
import { ImageZoomLevelProps } from './ImageZoomLevelProps'
|
||||
import { PreviewableTextFileTypes, RequiresNativeFilePreview } from './isFilePreviewable'
|
||||
import TextPreview from './TextPreview'
|
||||
import { parseFileName } from '@standardnotes/filepicker'
|
||||
import { sanitizeFileName } from '@standardnotes/ui-services'
|
||||
|
||||
type Props = {
|
||||
application: WebApplication
|
||||
@@ -55,7 +57,11 @@ const PreviewComponent: FunctionComponent<Props> = ({
|
||||
}),
|
||||
)
|
||||
|
||||
void application.mobileDevice().previewFile(fileBase64, file.name)
|
||||
const { name, ext } = parseFileName(file.name)
|
||||
const sanitizedName = sanitizeFileName(name)
|
||||
const filename = `${sanitizedName}.${ext}`
|
||||
|
||||
void application.mobileDevice().previewFile(fileBase64, filename)
|
||||
}, [application, bytes, file.mimeType, file.name, isNativeMobileWeb])
|
||||
|
||||
if (isNativeMobileWeb && requiresNativePreview) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user