fix: can't change or delete preview (#100)

This commit is contained in:
Hayden
2025-01-15 16:48:41 +08:00
committed by GitHub
parent 89c249542a
commit bfccc6f04f
10 changed files with 135 additions and 44 deletions

View File

@@ -26,3 +26,14 @@ export const bytesToSize = (
export const formatDate = (date: number | string | Date) => {
return dayjs(date).format('YYYY-MM-DD HH:mm:ss')
}
export const previewUrlToFile = async (url: string) => {
return fetch(url)
.then((res) => res.blob())
.then((blob) => {
const type = blob.type
const extension = type.split('/')[1]
const file = new File([blob], `preview.${extension}`, { type })
return file
})
}