mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
feat: add ctx.utils.downloadContent method
This commit is contained in:
@@ -76,6 +76,14 @@ export function objectInsertAfterKey (obj: {}, key: string, content: {}) {
|
||||
return Object.fromEntries(items)
|
||||
}
|
||||
|
||||
export function downloadContent (filename: string, content: Buffer | string, type = 'application/octet-stream') {
|
||||
const blob = new Blob([content], { type })
|
||||
const link = document.createElement('a')
|
||||
link.href = window.URL.createObjectURL(blob)
|
||||
link.download = filename
|
||||
link.click()
|
||||
}
|
||||
|
||||
export function md5 (content: any) {
|
||||
return CryptoJS.MD5(content).toString()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user