Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
I want to read download file from server using REST API using JavaScript as client code

What I am trying to achieve: I want to download a file from a file path on a server.

This is what is working I can see in swagger the download link API response. The download link works perfectly.

enter image description here

At Javascript code client-side in

enter image description here

This is my AngularJS JavaScipt code

fileDownload() {
    var deferredObj = $q.defer();

    psu = $resource("/download-file", {}, {
                 query: {
       method: 'GET',
       isArray: false,
       timeout: 30000,
       cancellable: true,
       responseType: 'arraybuffer',
       transformResponse: function(data,headers){
         response={},
         response.data=data;
         response.headers=headers();
         return response;
       }
     }
    }).query();
    psu.$promise.then(function(result) {
            deferredObj.resolve(result); details.
        },
        function(errorMsg) {
            console.log("Error in downloading file detail", errorMsg);
            deferredObj.reject(errorMsg);
        });
    return deferredObj.promise;
}

I am getting everything in the response, i.e. data and header.

How to save the downloaded file using JavaScript code?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!