#39 zip not created correctly
This commit is contained in:
Alan Grainger
2025-02-21 14:53:29 +08:00
parent 93f72a5ee8
commit 8f80ddcc23
4 changed files with 12 additions and 7 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "immich-public-proxy",
"version": "1.7.2",
"version": "1.7.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "immich-public-proxy",
"version": "1.7.2",
"version": "1.7.3",
"license": "AGPL-3.0",
"dependencies": {
"archiver": "^7.0.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "immich-public-proxy",
"version": "1.7.2",
"version": "1.7.3",
"scripts": {
"dev": "ts-node src/index.ts",
"build": "npx tsc",
+7 -2
View File
@@ -140,7 +140,7 @@ class Render {
res.setHeader('Content-Type', 'application/zip')
const title = this.title(share).replace(/[^\w .-]/g, '') + '.zip'
res.setHeader('Content-Disposition', `attachment; filename="${title}"`)
const archive = archiver('zip', { zlib: { level: 9 } })
const archive = archiver('zip', { zlib: { level: 6 } })
archive.pipe(res)
for (const asset of share.assets) {
const url = immich.buildUrl(immich.apiUrl() + '/assets/' + encodeURIComponent(asset.id) + '/original', {
@@ -148,10 +148,15 @@ class Render {
password: asset.password
})
const data = await fetch(url)
// Check the response for validity
if (!data.ok) {
console.warn(`Failed to fetch asset: ${asset.id}`)
continue
}
archive.append(Buffer.from(await data.arrayBuffer()), { name: asset.originalFileName || asset.id })
}
await archive.finalize()
res.end()
archive.on('end', () => res.end())
}
}