Skip to content

Commit

Permalink
refactor: asset media endpoints (#9831)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Zack Pollard <[email protected]>
  • Loading branch information
3 people authored May 31, 2024
1 parent 66fced4 commit 69d2fcb
Show file tree
Hide file tree
Showing 91 changed files with 1,854 additions and 2,378 deletions.
9 changes: 5 additions & 4 deletions cli/src/commands/asset.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
Action,
AssetBulkUploadCheckResult,
AssetFileUploadResponseDto,
AssetMediaResponseDto,
AssetMediaStatus,
addAssetsToAlbum,
checkBulkUpload,
createAlbum,
Expand Down Expand Up @@ -167,7 +168,7 @@ const uploadFiles = async (files: string[], { dryRun, concurrency }: UploadOptio

newAssets.push({ id: response.id, filepath });

if (response.duplicate) {
if (response.status === AssetMediaStatus.Duplicate) {
duplicateCount++;
duplicateSize += stats.size ?? 0;
} else {
Expand All @@ -192,7 +193,7 @@ const uploadFiles = async (files: string[], { dryRun, concurrency }: UploadOptio
return newAssets;
};

const uploadFile = async (input: string, stats: Stats): Promise<AssetFileUploadResponseDto> => {
const uploadFile = async (input: string, stats: Stats): Promise<AssetMediaResponseDto> => {
const { baseUrl, headers } = defaults;

const assetPath = path.parse(input);
Expand Down Expand Up @@ -225,7 +226,7 @@ const uploadFile = async (input: string, stats: Stats): Promise<AssetFileUploadR
formData.append('sidecarData', sidecarData);
}

const response = await fetch(`${baseUrl}/asset/upload`, {
const response = await fetch(`${baseUrl}/assets`, {
method: 'post',
redirect: 'error',
headers: headers as Record<string, string>,
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/python-file-upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def upload(file):
}

response = requests.post(
f'{BASE_URL}/asset/upload', headers=headers, data=data, files=files)
f'{BASE_URL}/assets', headers=headers, data=data, files=files)

print(response.json())
# {'id': 'ef96f635-61c7-4639-9e60-61a11c4bbfba', 'duplicate': False}
Expand Down
4 changes: 2 additions & 2 deletions e2e/src/api/specs/activity.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
ActivityCreateDto,
AlbumResponseDto,
AlbumUserRole,
AssetFileUploadResponseDto,
AssetMediaResponseDto,
LoginResponseDto,
ReactionType,
createActivity as create,
Expand All @@ -17,7 +17,7 @@ import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
describe('/activities', () => {
let admin: LoginResponseDto;
let nonOwner: LoginResponseDto;
let asset: AssetFileUploadResponseDto;
let asset: AssetMediaResponseDto;
let album: AlbumResponseDto;

const createActivity = (dto: ActivityCreateDto, accessToken?: string) =>
Expand Down
6 changes: 3 additions & 3 deletions e2e/src/api/specs/album.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
addAssetsToAlbum,
AlbumResponseDto,
AlbumUserRole,
AssetFileUploadResponseDto,
AssetMediaResponseDto,
AssetOrder,
deleteUserAdmin,
getAlbumInfo,
Expand All @@ -26,8 +26,8 @@ const user2NotShared = 'user2NotShared';
describe('/albums', () => {
let admin: LoginResponseDto;
let user1: LoginResponseDto;
let user1Asset1: AssetFileUploadResponseDto;
let user1Asset2: AssetFileUploadResponseDto;
let user1Asset1: AssetMediaResponseDto;
let user1Asset2: AssetMediaResponseDto;
let user1Albums: AlbumResponseDto[];
let user2: LoginResponseDto;
let user2Albums: AlbumResponseDto[];
Expand Down
Loading

0 comments on commit 69d2fcb

Please sign in to comment.