2017-09-20 34 views
6

Bir dosyayı indirdiğim bir uygulama oluşturuyorum. Bunun için ben js içinde java sınıfından yanıt almak ve bu benim java kodu bu response.For indirmek -IE11 dosyasında dosya indirme hatası "'Uint8Array' undefined"

@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(); 
} 

Ve JS kodu -

 $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); 
        }); 
} 

Bu

de bana hata vermek

var damla = yeni Kabarcık ([cevap], {türü: mimeType})

Hata olduğunu - " 'Uint8Array' tanımsız" ve benim IE versiyonu - IE11

+0

'Uint8Array' listelenen ilave edilir: //developer.mozilla .org/tr-tR/docs/Web/JavaScript/Referans/Global_Objects/Uint8Array. Kaydedilen başka bir hata var mı? – guest271314

cevap

3

My açısal versiyon 1.2.26 ve Uint8Array 1.5 açısal sonraki sürümünde desteklenen ve IE10 + HTTPS tanımlandığı üzere

<meta http-equiv="X-UA-Compatible" content="IE=11" /> 
0

Blob sen responseType: "blob" kullanabilirsiniz hata atmak etmezse.