mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
feat(server): improve API specification (#1853)
This commit is contained in:
@@ -93,6 +93,7 @@ describe('AlbumCard component', () => {
|
||||
expect(apiMock.assetApi.getAssetThumbnail).toHaveBeenCalledWith(
|
||||
'thumbnailIdOne',
|
||||
ThumbnailFormat.Jpeg,
|
||||
undefined,
|
||||
{ responseType: 'blob' }
|
||||
);
|
||||
expect(createObjectURLMock).toHaveBeenCalledWith(thumbnailBlob);
|
||||
|
||||
@@ -34,9 +34,14 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const { data } = await api.assetApi.getAssetThumbnail(thubmnailId, ThumbnailFormat.Jpeg, {
|
||||
responseType: 'blob'
|
||||
});
|
||||
const { data } = await api.assetApi.getAssetThumbnail(
|
||||
thubmnailId,
|
||||
ThumbnailFormat.Jpeg,
|
||||
undefined,
|
||||
{
|
||||
responseType: 'blob'
|
||||
}
|
||||
);
|
||||
|
||||
if (data instanceof Blob) {
|
||||
return URL.createObjectURL(data);
|
||||
|
||||
@@ -170,11 +170,7 @@
|
||||
{
|
||||
assetIds: assets.map((a) => a.id)
|
||||
},
|
||||
{
|
||||
params: {
|
||||
key: sharedLink?.key
|
||||
}
|
||||
}
|
||||
sharedLink?.key
|
||||
);
|
||||
|
||||
if (data.album) {
|
||||
@@ -269,10 +265,8 @@
|
||||
const { data, status, headers } = await api.albumApi.downloadArchive(
|
||||
album.id,
|
||||
skip || undefined,
|
||||
sharedLink?.key,
|
||||
{
|
||||
params: {
|
||||
key: sharedLink?.key
|
||||
},
|
||||
responseType: 'blob',
|
||||
onDownloadProgress: function (progressEvent) {
|
||||
const request = this as XMLHttpRequest;
|
||||
|
||||
@@ -145,8 +145,7 @@
|
||||
|
||||
$downloadAssets[imageFileName] = 0;
|
||||
|
||||
const { data, status } = await api.assetApi.downloadFile(assetId, {
|
||||
params: { key },
|
||||
const { data, status } = await api.assetApi.downloadFile(assetId, key, {
|
||||
responseType: 'blob',
|
||||
onDownloadProgress: (progressEvent) => {
|
||||
if (progressEvent.lengthComputable) {
|
||||
|
||||
@@ -26,10 +26,7 @@
|
||||
|
||||
const loadAssetData = async () => {
|
||||
try {
|
||||
const { data } = await api.assetApi.serveFile(asset.id, false, true, {
|
||||
params: {
|
||||
key: publicSharedKey
|
||||
},
|
||||
const { data } = await api.assetApi.serveFile(asset.id, false, true, publicSharedKey, {
|
||||
responseType: 'blob'
|
||||
});
|
||||
|
||||
|
||||
@@ -54,11 +54,7 @@
|
||||
{
|
||||
assetIds
|
||||
},
|
||||
{
|
||||
params: {
|
||||
key: sharedLink?.key
|
||||
}
|
||||
}
|
||||
sharedLink?.key
|
||||
);
|
||||
|
||||
notificationController.show({
|
||||
@@ -76,11 +72,7 @@
|
||||
{
|
||||
assetIds: assets.filter((a) => !selectedAssets.has(a)).map((a) => a.id)
|
||||
},
|
||||
{
|
||||
params: {
|
||||
key: sharedLink?.key
|
||||
}
|
||||
}
|
||||
sharedLink?.key
|
||||
);
|
||||
|
||||
assets = assets.filter((a) => !selectedAssets.has(a));
|
||||
|
||||
@@ -11,9 +11,14 @@
|
||||
return noThumbnailUrl;
|
||||
}
|
||||
|
||||
const { data } = await api.assetApi.getAssetThumbnail(thubmnailId, ThumbnailFormat.Webp, {
|
||||
responseType: 'blob'
|
||||
});
|
||||
const { data } = await api.assetApi.getAssetThumbnail(
|
||||
thubmnailId,
|
||||
ThumbnailFormat.Webp,
|
||||
undefined,
|
||||
{
|
||||
responseType: 'blob'
|
||||
}
|
||||
);
|
||||
if (data instanceof Blob) {
|
||||
return URL.createObjectURL(data);
|
||||
}
|
||||
|
||||
@@ -18,19 +18,17 @@ export const addAssetsToAlbum = async (
|
||||
assetIds: Array<string>,
|
||||
key: string | undefined = undefined
|
||||
): Promise<AddAssetsResponseDto> =>
|
||||
api.albumApi
|
||||
.addAssetsToAlbum(albumId, { assetIds }, { params: { key } })
|
||||
.then(({ data: dto }) => {
|
||||
if (dto.successfullyAdded > 0) {
|
||||
// This might be 0 if the user tries to add an asset that is already in the album
|
||||
notificationController.show({
|
||||
message: `Added ${dto.successfullyAdded} to ${dto.album?.albumName}`,
|
||||
type: NotificationType.Info
|
||||
});
|
||||
}
|
||||
api.albumApi.addAssetsToAlbum(albumId, { assetIds }, key).then(({ data: dto }) => {
|
||||
if (dto.successfullyAdded > 0) {
|
||||
// This might be 0 if the user tries to add an asset that is already in the album
|
||||
notificationController.show({
|
||||
message: `Added ${dto.successfullyAdded} to ${dto.album?.albumName}`,
|
||||
type: NotificationType.Info
|
||||
});
|
||||
}
|
||||
|
||||
return dto;
|
||||
});
|
||||
return dto;
|
||||
});
|
||||
|
||||
export async function bulkDownload(
|
||||
fileName: string,
|
||||
@@ -53,24 +51,20 @@ export async function bulkDownload(
|
||||
|
||||
let total = 0;
|
||||
|
||||
const { data, status, headers } = await api.assetApi.downloadFiles(
|
||||
{ assetIds },
|
||||
{
|
||||
params: { key },
|
||||
responseType: 'blob',
|
||||
onDownloadProgress: function (progressEvent) {
|
||||
const request = this as XMLHttpRequest;
|
||||
if (!total) {
|
||||
total = Number(request.getResponseHeader('X-Immich-Content-Length-Hint')) || 0;
|
||||
}
|
||||
const { data, status, headers } = await api.assetApi.downloadFiles({ assetIds }, key, {
|
||||
responseType: 'blob',
|
||||
onDownloadProgress: function (progressEvent) {
|
||||
const request = this as XMLHttpRequest;
|
||||
if (!total) {
|
||||
total = Number(request.getResponseHeader('X-Immich-Content-Length-Hint')) || 0;
|
||||
}
|
||||
|
||||
if (total) {
|
||||
const current = progressEvent.loaded;
|
||||
downloadAssets.set({ [downloadFileName]: Math.floor((current / total) * 100) });
|
||||
}
|
||||
if (total) {
|
||||
const current = progressEvent.loaded;
|
||||
downloadAssets.set({ [downloadFileName]: Math.floor((current / total) * 100) });
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
const isNotComplete = headers['x-immich-archive-complete'] === 'false';
|
||||
const fileCount = Number(headers['x-immich-archive-file-count']) || 0;
|
||||
|
||||
@@ -108,11 +108,7 @@ async function fileUploader(
|
||||
deviceAssetId: String(deviceAssetId),
|
||||
deviceId: 'WEB'
|
||||
},
|
||||
{
|
||||
params: {
|
||||
key: sharedKey
|
||||
}
|
||||
}
|
||||
sharedKey
|
||||
);
|
||||
|
||||
if (status === 200 && data.isExist && data.id) {
|
||||
|
||||
Reference in New Issue
Block a user