Skip to content

Commit

Permalink
fix(FEC-13452): download not working for image if no attachments (#28)
Browse files Browse the repository at this point in the history
### Description of the Changes

**the issue:**
in image entry case, there are no flavors and no captions, but there might be attachments. in case there are no attachments as well, the request to BE to get the downloadUrls is failing; therefore, the download icon is absent.

**solution:**
make the multiRequest to get the download urls, only if at least 1 of the arrays (flavors/captions/attachments) is not empty.

Solves FEC-13452
  • Loading branch information
lianbenjamin authored Nov 2, 2023
1 parent 99ebfef commit 2155862
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/services/download-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ class DownloadService {
const assets = await this.getKalturaAssets();
Object.assign(metadata, assets);
metadata!.imageDownloadUrl = await this.handleImageDownload();
const downloadUrls: Map<string, string> = await this.getDownloadUrls(metadata);

// assign the download urls to the assets by id
metadata.flavors = this.setDownloadUrls(metadata?.flavors, downloadUrls);
metadata.captions = this.setDownloadUrls(metadata?.captions, downloadUrls);
metadata.attachments = this.setDownloadUrls(metadata?.attachments, downloadUrls);
if (metadata?.flavors.length || metadata?.captions.length || metadata?.attachments.length) {
const downloadUrls: Map<string, string> = await this.getDownloadUrls(metadata);

// assign the download urls to the assets by id
metadata.flavors = this.setDownloadUrls(metadata?.flavors, downloadUrls);
metadata.captions = this.setDownloadUrls(metadata?.captions, downloadUrls);
metadata.attachments = this.setDownloadUrls(metadata?.attachments, downloadUrls);
}

metadata!.fileName = this.getFilename(metadata);
return metadata;
Expand Down

0 comments on commit 2155862

Please sign in to comment.