File Transfer plugin issue ionic 2


#1

this.fileTransfer.download(url,path,true,options).then((entry) => {

console.log('download complete: ’ + entry.toURL());
this.fileOpener.open(entry.toURL(), ‘application/pdf’).then(() => console.log(‘File is opened’))
.catch(e => console.log(‘Error openening file’, e));

}, (error) => {
console.log(error);
});

////server side code

// get MIME type of the file
String mimeType = context.getMimeType(destinationLocation);
if (mimeType == null) {
// set to binary type if MIME mapping not found
mimeType = “application/octet-stream”;
}
response.setContentType(mimeType);
response.setContentLength((int) downloadFile.length());
// set headers for the response
/* String headerKey = “Content-Disposition”;
String headerValue = String.format(“attachment; filename=”%s"", downloadFile.getName());
response.setHeader(headerKey, headerValue);*/

    // get output stream of the response
    OutputStream outStream = response.getOutputStream();

    byte[] buffer = new byte[Constants.Values.BUFFER_SIZE];
    int bytesRead = -1;

    // write bytes read from the input stream into the output stream
    while ((bytesRead = inputStream.read(buffer)) != -1) {
        outStream.write(buffer, 0, bytesRead);
    }

    inputStream.close();
    outStream.close();

Iam downloading a pdf file from server using mimetype and saving it in the location using file transfer. It is not throwing any error but it is not saving any file also.
The URL i added is working file in postman