Skip to content

Commit

Permalink
Merge pull request #354 from usnistgov/fix/zipfile-naming
Browse files Browse the repository at this point in the history
Rename Bundle Name
  • Loading branch information
chuanlin2018 authored Dec 19, 2024
2 parents f87ccdc + 1fb30d4 commit 36df4b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 8 additions & 7 deletions angular/src/app/datacart/bundleplan/bundleplan.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,13 @@ export class BundleplanComponent implements OnInit {
this.downloadService.download(zip, this.zipData, this.dataCart);
}

private generateZipFileName(base : string = null) : string {
const MIN : number = 0;
const MAX : number = 100000;
let suffix = Math.floor(Math.random() * (MAX - MIN + 1)) + MIN;
return base + suffix;
}
private generateZipFileName(base: string = "NIST-Data"): string {
// current timestamp
const now = new Date();
const timestamp = now.toISOString().slice(0, 16).replace(":", "-");

return `${base}-${timestamp}`;
}

/**
* download the selected files from this cart.
Expand All @@ -306,7 +307,7 @@ export class BundleplanComponent implements OnInit {

// Sending data to _bundle_plan and get back the plan
this.downloadFiles = this.dataCart.getSelectedFiles();
let bundleBaseName = this.generateZipFileName(this.dataCart.getName());
let bundleBaseName = this.generateZipFileName("NIST-Data");

this.bundlePlanRef = this.downloadService.getBundlePlan(bundleBaseName, this.downloadFiles).subscribe(
blob => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export class DownloadService {
// create the request body
let reqfiles = [];
for (let item of files) {
let resId = item.resId;
let filePath = item.filePath;
console.log(`resId: ${resId}, filePath: ${filePath}`);

reqfiles.push({
"filePath": item.resId + '/' + item.filePath,
"downloadUrl": item.downloadURL
Expand Down

0 comments on commit 36df4b3

Please sign in to comment.