Remove buffering for single downloads #94
This commit is contained in:
+11
-8
@@ -96,14 +96,17 @@ export async function assetBuffer (req: IncomingShareRequest, res: Response, ass
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attachment && asset.originalFileName) {
|
if (attachment) {
|
||||||
// Playback downloads serve Immich's transcode, so the filename extension
|
res.setHeader('X-Accel-Buffering', 'no')
|
||||||
// must follow the response's content-type, not the original file's.
|
if (asset.originalFileName) {
|
||||||
const playbackMime = useVideoPlayback
|
// Playback downloads serve Immich's transcode, so the filename extension
|
||||||
? (data.headers.get('content-type') || '').split(';')[0].trim() || undefined
|
// must follow the response's content-type, not the original file's.
|
||||||
: undefined
|
const playbackMime = useVideoPlayback
|
||||||
const filename = encodeURI(getFilename(asset, servedSize, playbackMime))
|
? (data.headers.get('content-type') || '').split(';')[0].trim() || undefined
|
||||||
res.setHeader('Content-Disposition', `attachment; filename*=UTF-8''${filename}`)
|
: undefined
|
||||||
|
const filename = encodeURI(getFilename(asset, servedSize, playbackMime))
|
||||||
|
res.setHeader('Content-Disposition', `attachment; filename*=UTF-8''${filename}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
headerList.forEach(header => {
|
headerList.forEach(header => {
|
||||||
const value = data.headers.get(header)
|
const value = data.headers.get(header)
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ describe('assetBuffer streaming', () => {
|
|||||||
expect(res.headers['content-type']).toBe('image/jpeg')
|
expect(res.headers['content-type']).toBe('image/jpeg')
|
||||||
expect(res.headers['content-length']).toBe(String(4 * CHUNK))
|
expect(res.headers['content-length']).toBe(String(4 * CHUNK))
|
||||||
expect(res.headers['content-disposition']).toContain('a1.jpg')
|
expect(res.headers['content-disposition']).toContain('a1.jpg')
|
||||||
|
expect(res.headers['x-accel-buffering']).toBe('no')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('applies backpressure so upstream is read no faster than the visitor drains it', async () => {
|
it('applies backpressure so upstream is read no faster than the visitor drains it', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user