1
0
mirror of https://github.com/immich-app/immich.git synced 2025-06-15 03:30:33 +02:00

chore(server) refactor serveFile and downloadFile endpoint (#978)

This commit is contained in:
Alex
2022-11-16 00:11:16 -06:00
committed by GitHub
parent 1db255fd3e
commit e799f35dd2
19 changed files with 116 additions and 175 deletions

View File

@ -101,22 +101,16 @@
$downloadAssets[imageFileName] = 0;
const { data, status } = await api.assetApi.downloadFile(
asset.deviceAssetId,
asset.deviceId,
false,
false,
{
responseType: 'blob',
onDownloadProgress: (progressEvent) => {
if (progressEvent.lengthComputable) {
const total = progressEvent.total;
const current = progressEvent.loaded;
$downloadAssets[imageFileName] = Math.floor((current / total) * 100);
}
const { data, status } = await api.assetApi.downloadFile(asset.id, false, false, {
responseType: 'blob',
onDownloadProgress: (progressEvent) => {
if (progressEvent.lengthComputable) {
const total = progressEvent.total;
const current = progressEvent.loaded;
$downloadAssets[imageFileName] = Math.floor((current / total) * 100);
}
}
);
});
if (!(data instanceof Blob)) {
return;
@ -262,7 +256,7 @@
<div class="row-start-1 row-span-full col-start-1 col-span-4">
{#key asset.id}
{#if asset.type === AssetTypeEnum.Image}
<PhotoViewer assetId={asset.id} deviceId={asset.deviceId} on:close={closeViewer} />
<PhotoViewer assetId={asset.id} on:close={closeViewer} />
{:else}
<VideoViewer assetId={asset.id} on:close={closeViewer} />
{/if}