mirror of
https://github.com/gtsteffaniak/filebrowser.git
synced 2026-11-17 22:39:42 -05:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7eda40a77a |
No files matched your search
@@ -2,6 +2,11 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. For commit guidelines, please refer to [Standard Version](https://github.com/conventional-changelog/standard-version).
|
||||
|
||||
## v1.0.3-stable
|
||||
|
||||
**BugFixes**:
|
||||
- download progress is not shown #1687
|
||||
|
||||
## v1.0.2-stable
|
||||
|
||||
**Notes**:
|
||||
|
||||
@@ -102,56 +102,18 @@ export async function download(format, files, shareHash = "") {
|
||||
files: fileargs,
|
||||
algo: format,
|
||||
hash: shareHash,
|
||||
...(state.share.token && { token: state.share.token })
|
||||
...(state.share.token && { token: state.share.token }),
|
||||
sessionId: state.sessionId
|
||||
})
|
||||
const url = window.origin + apiPath
|
||||
|
||||
// Use fetch to capture errors in the console
|
||||
const response = await fetch(url, {
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
"sessionId": state.sessionId,
|
||||
},
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text()
|
||||
const error = new Error(`Download failed: ${response.status} ${response.statusText}`)
|
||||
console.error('Download API error:', {
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
body: errorText,
|
||||
url: url
|
||||
})
|
||||
throw error
|
||||
}
|
||||
|
||||
// Get the blob from the response
|
||||
const blob = await response.blob()
|
||||
// Determine filename from Content-Disposition header or use default
|
||||
let filename = 'download'
|
||||
const contentDisposition = response.headers.get('Content-Disposition')
|
||||
if (contentDisposition) {
|
||||
const filenameMatch = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/)
|
||||
if (filenameMatch && filenameMatch[1]) {
|
||||
filename = filenameMatch[1].replace(/['"]/g, '')
|
||||
}
|
||||
} else {
|
||||
// Fallback: use format extension
|
||||
filename = `download.${format}`
|
||||
}
|
||||
|
||||
// Create a blob URL and trigger download
|
||||
const blobUrl = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = blobUrl
|
||||
link.setAttribute('download', filename)
|
||||
link.href = url
|
||||
link.style.display = 'none'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
// Clean up the blob URL
|
||||
window.URL.revokeObjectURL(blobUrl)
|
||||
|
||||
setTimeout(() => {
|
||||
document.body.removeChild(link)
|
||||
}, 100)
|
||||
}
|
||||
|
||||
export function post(
|
||||
|
||||
Reference in new issue
Block a user