1
0
mirror of https://github.com/immich-app/immich.git synced 2025-07-06 06:07:29 +02:00

refactor: asset media endpoints (#9831)

* refactor: asset media endpoints

* refactor: mobile upload livePhoto as separate request

* refactor: change mobile backup flow to use new asset upload endpoints

* chore: format and analyze dart code

* feat: mark motion as hidden when linked

* feat: upload video portion of live photo before image portion

* fix: incorrect assetApi calls in mobile code

* fix: download asset

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
Co-authored-by: Zack Pollard <zackpollard@ymail.com>
This commit is contained in:
Jason Rasmussen
2024-05-31 13:44:04 -04:00
committed by GitHub
parent 66fced40e7
commit 69d2fcb43e
91 changed files with 1932 additions and 2456 deletions

View File

@ -6,23 +6,23 @@ import 'package:openapi/api.dart';
String getThumbnailUrl(
final Asset asset, {
ThumbnailFormat type = ThumbnailFormat.WEBP,
AssetMediaSize type = AssetMediaSize.thumbnail,
}) {
return getThumbnailUrlForRemoteId(asset.remoteId!, type: type);
}
String getThumbnailCacheKey(
final Asset asset, {
ThumbnailFormat type = ThumbnailFormat.WEBP,
AssetMediaSize type = AssetMediaSize.thumbnail,
}) {
return getThumbnailCacheKeyForRemoteId(asset.remoteId!, type: type);
}
String getThumbnailCacheKeyForRemoteId(
final String id, {
ThumbnailFormat type = ThumbnailFormat.WEBP,
AssetMediaSize type = AssetMediaSize.thumbnail,
}) {
if (type == ThumbnailFormat.WEBP) {
if (type == AssetMediaSize.thumbnail) {
return 'thumbnail-image-$id';
} else {
return '${id}_previewStage';
@ -31,7 +31,7 @@ String getThumbnailCacheKeyForRemoteId(
String getAlbumThumbnailUrl(
final Album album, {
ThumbnailFormat type = ThumbnailFormat.WEBP,
AssetMediaSize type = AssetMediaSize.thumbnail,
}) {
if (album.thumbnail.value?.remoteId == null) {
return '';
@ -44,7 +44,7 @@ String getAlbumThumbnailUrl(
String getAlbumThumbNailCacheKey(
final Album album, {
ThumbnailFormat type = ThumbnailFormat.WEBP,
AssetMediaSize type = AssetMediaSize.thumbnail,
}) {
if (album.thumbnail.value?.remoteId == null) {
return '';
@ -60,7 +60,7 @@ String getImageUrl(final Asset asset) {
}
String getImageUrlFromId(final String id) {
return '${Store.get(StoreKey.serverEndpoint)}/asset/file/$id?isThumb=false';
return '${Store.get(StoreKey.serverEndpoint)}/assets/$id/thumbnail?size=preview';
}
String getImageCacheKey(final Asset asset) {
@ -71,9 +71,9 @@ String getImageCacheKey(final Asset asset) {
String getThumbnailUrlForRemoteId(
final String id, {
ThumbnailFormat type = ThumbnailFormat.WEBP,
AssetMediaSize type = AssetMediaSize.thumbnail,
}) {
return '${Store.get(StoreKey.serverEndpoint)}/asset/thumbnail/$id?format=${type.value}';
return '${Store.get(StoreKey.serverEndpoint)}/assets/$id/thumbnail?format=${type.value}';
}
String getFaceThumbnailUrl(final String personId) {