मैं एक ऐसा एप्लिकेशन बना रहा हूं जिसमें मैं एक फ़ाइल डाउनलोड कर रहा हूं। इसके लिए मैं js में जावा वर्ग से प्रतिक्रिया प्राप्त करते हैं और इस response.For डाउनलोड यह मेरा जावा कोड है -आईई 11 में फ़ाइल डाउनलोड करें त्रुटि प्राप्त करें "'Uint8Array' अपरिभाषित है"
@ApiOperation(value = "",
notes = "")
@Path("/getProjectJSONTODRAW/{implementation}")
@GET
@Timed
public Response getProjectJSONTODRAW(@PathParam("implementation") String implementation) {
File file = new File(path+File.separator+fileName);
InputStream inputStream =null;
String mimeType =null;
if (!file.exists()) {
String errorMessage = "Sorry. The file you are looking for does not exist";
log.info(errorMessage);
}else {
mimeType = URLConnection.guessContentTypeFromName(file.getName());
if (mimeType == null) {
log.info("mimetype is not detectable, will take default for the file "+file.getName());
mimeType = "application/octet-stream";
}
try {
inputStream = new BufferedInputStream(new FileInputStream(file));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
return Response
.ok(inputStream, mimeType)
.header("Content-Disposition", "attachment; filename=\""+file.getName()+"\"")
.header("Content-Length", file.length())
.build();
}
और जे एस में कोड है -
$http.get('/api/1/explore/getProjectJSONTODRAW/implementation', {
responseType: 'arraybuffer'
})
.success(function(response) {
var a = document.createElement("a");
document.body.appendChild(a);
var fileName = "abc.pdf";
var mimeType = "application/pdf";
var blob = new Blob([response], {
type: mimeType
}),
url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
var isIE = false || !!document.documentMode;
if (isIE) {
a.style.cssText = "display: none;"
window.navigator.msSaveOrOpenBlob(blob, fileName);
} else {
a.style = "display: none";
a.click();
window.URL.revokeObjectURL(url);
}
}).catch(function(error) {
console.log(error);
});
}
यह मैं
में त्रुटि दिखा सकते हैंवर ब्लॉब = नए ब्लॉब ([प्रतिक्रिया], {प्रकार: MIMETYPE})
त्रुटि है - " 'Uint8Array' अपरिभाषित है" और मेरे आईई संस्करण है - IE11
'Uint8Array' सूचीबद्ध है: //developer.mozilla .org/en-US/docs/वेब/जावास्क्रिप्ट/संदर्भ/Global_Objects/Uint8Array। क्या कोई अन्य त्रुटियां लॉग हैं? – guest271314