You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-07-03 05:46:58 +02:00
feat: API operation replaceAsset, POST /api/asset/:id/file (#9684)
* impl and unit tests for replaceAsset * Remove it.only * Typo in generated spec +regen * Remove unused dtos * Dto removal fallout/bugfix * fix - missed a line * sql:generate * Review comments * Unused imports * chore: clean up --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
@ -324,6 +324,18 @@ export type UpdateAssetDto = {
|
||||
latitude?: number;
|
||||
longitude?: number;
|
||||
};
|
||||
export type AssetMediaReplaceDto = {
|
||||
assetData: Blob;
|
||||
deviceAssetId: string;
|
||||
deviceId: string;
|
||||
duration?: string;
|
||||
fileCreatedAt: string;
|
||||
fileModifiedAt: string;
|
||||
};
|
||||
export type AssetMediaResponseDto = {
|
||||
id: string;
|
||||
status: AssetMediaStatus;
|
||||
};
|
||||
export type AuditDeletesResponseDto = {
|
||||
ids: string[];
|
||||
needsFullSync: boolean;
|
||||
@ -1585,6 +1597,25 @@ export function updateAsset({ id, updateAssetDto }: {
|
||||
body: updateAssetDto
|
||||
})));
|
||||
}
|
||||
/**
|
||||
* Replace the asset with new file, without changing its id
|
||||
*/
|
||||
export function replaceAsset({ id, key, assetMediaReplaceDto }: {
|
||||
id: string;
|
||||
key?: string;
|
||||
assetMediaReplaceDto: AssetMediaReplaceDto;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: AssetMediaResponseDto;
|
||||
}>(`/asset/${encodeURIComponent(id)}/file${QS.query(QS.explode({
|
||||
key
|
||||
}))}`, oazapfts.multipart({
|
||||
...opts,
|
||||
method: "PUT",
|
||||
body: assetMediaReplaceDto
|
||||
})));
|
||||
}
|
||||
export function getAuditDeletes({ after, entityType, userId }: {
|
||||
after: string;
|
||||
entityType: EntityType;
|
||||
@ -2892,6 +2923,10 @@ export enum ThumbnailFormat {
|
||||
Jpeg = "JPEG",
|
||||
Webp = "WEBP"
|
||||
}
|
||||
export enum AssetMediaStatus {
|
||||
Replaced = "replaced",
|
||||
Duplicate = "duplicate"
|
||||
}
|
||||
export enum EntityType {
|
||||
Asset = "ASSET",
|
||||
Album = "ALBUM"
|
||||
|
Reference in New Issue
Block a user