chore(server): save original file name with extension (#7679)

* chore(server): save original file name with extension

* extract extension

* update e2e test

* update e2e test

* download archive

* fix download archive appending name

* pr feedback

* remove unused code

* test

* unit test

* remove unused code

* migration

* noops

* pr feedback

* Update server/src/domain/download/download.service.ts

Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com>

---------

Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com>
This commit is contained in:
Alex 2024-03-06 20:34:55 -06:00 committed by GitHub
parent f88343019d
commit 3da2b05428
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 72 additions and 17 deletions

View file

@ -609,6 +609,42 @@ describe(`${AssetController.name} (e2e)`, () => {
expect(asset).toMatchObject({ id: body.id, isFavorite: true });
});
it('should have correct original file name and extension (simple)', async () => {
const { body, status } = await request(server)
.post('/asset/upload')
.set('Authorization', `Bearer ${user1.accessToken}`)
.field('deviceAssetId', 'example-image')
.field('deviceId', 'TEST')
.field('fileCreatedAt', new Date().toISOString())
.field('fileModifiedAt', new Date().toISOString())
.field('isFavorite', 'true')
.field('duration', '0:00:00.000000')
.attach('assetData', randomBytes(32), 'example.jpg');
expect(status).toBe(201);
expect(body).toEqual({ id: expect.any(String), duplicate: false });
const asset = await api.assetApi.get(server, user1.accessToken, body.id);
expect(asset).toMatchObject({ id: body.id, originalFileName: 'example.jpg' });
});
it('should have correct original file name and extension (complex)', async () => {
const { body, status } = await request(server)
.post('/asset/upload')
.set('Authorization', `Bearer ${user1.accessToken}`)
.field('deviceAssetId', 'example-image')
.field('deviceId', 'TEST')
.field('fileCreatedAt', new Date().toISOString())
.field('fileModifiedAt', new Date().toISOString())
.field('isFavorite', 'true')
.field('duration', '0:00:00.000000')
.attach('assetData', randomBytes(32), 'example.complex.ext.jpg');
expect(status).toBe(201);
expect(body).toEqual({ id: expect.any(String), duplicate: false });
const asset = await api.assetApi.get(server, user1.accessToken, body.id);
expect(asset).toMatchObject({ id: body.id, originalFileName: 'example.complex.ext.jpg' });
});
it('should not upload the same asset twice', async () => {
const content = randomBytes(32);
await api.assetApi.upload(server, user1.accessToken, 'example-image', { content });