0

In postman response, the output is a URL that contains a https link to google cloud storage which contains a zip folder. This . zip folder contains an excel and a pdf file.

I am looking for one of these solutions.

  1. Either use javascript to download the zip folder, parse it and validate the contents in the folder. i.e assert to ensure the content of the zip folder contains an excel and a pdf file.

  2. Make a GET request directly to gcs API via encoded url to get the contents of the zip folder. At the moment I can get to gcs cloud API, it seems to provide me with metadata, not the contents of the zip folder

For the 2nd solution, I have tried using this URL to get to the GCS https://www.googleapis.com/storage/v1/b/gcs-bucket-service/o/361b6d18-3881-49ed-994b-442574%2Freport_1.zip

This provides the metadata

I would be happy for either of the solutions to work

Jhanz
  • 127
  • 3
  • 3
  • 12

1 Answers1

0

You can't have an AJAX request open the download prompt since you physically have to navigate to the file to prompt for download. Instead, you could use a success function to navigate to download.php. This will open the download prompt but won't change the current page.

$.ajax({
url: 'download.php',
type: 'POST',
success: function() {
    window.location = 'download.php';
   }
});
Diego Felipe
  • 386
  • 5
  • 19