-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Transformed image names to image url while sending imported data
- Loading branch information
1 parent
4731bce
commit 94203a4
Showing
12 changed files
with
89 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
apps/api/src/app/upload/usecases/get-asset/get-asset.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Readable } from 'stream'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { UploadRepository } from '@impler/dal'; | ||
import { FileNameService } from '@impler/shared'; | ||
import { StorageService } from '@impler/shared/dist/services/storage'; | ||
import { DocumentNotFoundException } from '@shared/exceptions/document-not-found.exception'; | ||
|
||
@Injectable() | ||
export class GetAsset { | ||
constructor( | ||
private uploadRepository: UploadRepository, | ||
private storageService: StorageService, | ||
private fileNameService: FileNameService | ||
) {} | ||
|
||
async execute(_uploadId: string, name: string): Promise<Readable> { | ||
const upload = await this.uploadRepository.findById(_uploadId, '_id'); | ||
if (!upload) { | ||
throw new DocumentNotFoundException('Upload', _uploadId); | ||
} | ||
|
||
try { | ||
return await this.storageService.getFileStream(this.fileNameService.getAssetFilePath(_uploadId, name)); | ||
} catch (error) { | ||
throw new DocumentNotFoundException('Asset', name); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters