Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, Input, OnInit } from '@angular/core';
import { encodeRFC3986URIComponent } from '../../shared/clarin-shared-util';
import { Item } from '../../core/shared/item.model';
import { getAllSucceededRemoteListPayload, getFirstSucceededRemoteDataPayload } from '../../core/shared/operators';
import { getItemPageRoute } from '../item-page-routing-paths';
Expand Down Expand Up @@ -107,10 +108,20 @@ export class ClarinFilesSectionComponent implements OnInit {
return file.name;
});

// Generate curl command for individual bitstream downloads
const baseUrl = `${this.halService.getRootHref()}/bitstream/${this.itemHandle}`;
const fileNamesFormatted = fileNames.map((fileName, index) => `/${index}/${fileName}`).join(',');
this.command = `curl -O ${baseUrl}{${fileNamesFormatted}}`;
// Generate curl command for individual bitstream downloads by handle + filename.
// Uses the backend endpoint: /api/core/bitstreams/handle/{prefix}/{suffix}/{filename}
// -J tells curl to use the filename from the Content-Disposition header (the real name)
// instead of the percent-encoded URL path.
const baseUrl = `${this.halService.getRootHref()}/core/bitstreams/handle/${this.itemHandle}`;
const fileNamesFormatted = fileNames.map(fileName => `/${this.encodeFilenameForUrl(fileName)}`).join(',');
this.command = `curl -OJ "${baseUrl}{${fileNamesFormatted}}"`;
}

/**
* Encode a filename for use in a URL path segment using the shared RFC3986 utility.
*/
private encodeFilenameForUrl(filename: string): string {
return encodeRFC3986URIComponent(filename);
}

loadDownloadZipConfigProperties() {
Expand Down