Fix #15 Support live photos and HEIC images
This commit is contained in:
parent
5f502a215a
commit
1daf6c1c4b
@ -2,7 +2,7 @@ import express from 'express'
|
|||||||
import immich from './immich'
|
import immich from './immich'
|
||||||
import render from './render'
|
import render from './render'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { AssetType } from './types'
|
import { AssetType, ImageSize } from './types'
|
||||||
import { decrypt } from './encrypt'
|
import { decrypt } from './encrypt'
|
||||||
import { log, toString, addResponseHeaders } from './functions'
|
import { log, toString, addResponseHeaders } from './functions'
|
||||||
|
|
||||||
@ -36,6 +36,12 @@ app.get('/:type(photo|video)/:key/:id/:size?', async (req, res) => {
|
|||||||
addResponseHeaders(res)
|
addResponseHeaders(res)
|
||||||
// Check for valid key and ID
|
// Check for valid key and ID
|
||||||
if (immich.isKey(req.params.key) && immich.isId(req.params.id)) {
|
if (immich.isKey(req.params.key) && immich.isId(req.params.id)) {
|
||||||
|
// Validate the size parameter
|
||||||
|
if (req.params.size && !Object.values(ImageSize).includes(req.params.size as ImageSize)) {
|
||||||
|
log('Invalid size parameter ' + req.path)
|
||||||
|
res.status(404).send()
|
||||||
|
return
|
||||||
|
}
|
||||||
let password
|
let password
|
||||||
// Validate the password payload, if one was provided
|
// Validate the password payload, if one was provided
|
||||||
if (req.query?.cr && req.query?.iv) {
|
if (req.query?.cr && req.query?.iv) {
|
||||||
@ -59,7 +65,7 @@ app.get('/:type(photo|video)/:key/:id/:size?', async (req, res) => {
|
|||||||
const asset = sharedLink.assets.find(x => x.id === req.params.id)
|
const asset = sharedLink.assets.find(x => x.id === req.params.id)
|
||||||
if (asset) {
|
if (asset) {
|
||||||
asset.type = req.params.type === 'video' ? AssetType.video : AssetType.image
|
asset.type = req.params.type === 'video' ? AssetType.video : AssetType.image
|
||||||
render.assetBuffer(request, res, asset, immich.validateImageSize(req.params.size)).then()
|
render.assetBuffer(request, res, asset, req.params.size).then()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ class Render {
|
|||||||
/**
|
/**
|
||||||
* Stream data from Immich back to the client
|
* Stream data from Immich back to the client
|
||||||
*/
|
*/
|
||||||
async assetBuffer (req: IncomingShareRequest, res: Response, asset: Asset, size?: ImageSize) {
|
async assetBuffer (req: IncomingShareRequest, res: Response, asset: Asset, size?: ImageSize | string) {
|
||||||
// Prepare the request
|
// Prepare the request
|
||||||
const headerList = ['content-type', 'content-length', 'last-modified', 'etag']
|
const headerList = ['content-type', 'content-length', 'last-modified', 'etag']
|
||||||
size = immich.validateImageSize(size)
|
size = immich.validateImageSize(size)
|
||||||
|
Loading…
Reference in New Issue
Block a user