當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Response.blob方法代碼示例

本文整理匯總了TypeScript中@angular/http.Response.blob方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Response.blob方法的具體用法?TypeScript Response.blob怎麽用?TypeScript Response.blob使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular/http.Response的用法示例。


在下文中一共展示了Response.blob方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: switch

    return this.http.request(request).map( (response: Response) => {
        let resp: any;
        // handle response by expected responsetype
        switch (request.responseType) {
          case (ResponseContentType.Json):
            resp = response.json();
            break;
          case (ResponseContentType.Text):
            resp = response.text();
            break;
          case (ResponseContentType.Blob):
            resp = response.blob();
            break;
          case (ResponseContentType.ArrayBuffer):
            resp = response.arrayBuffer();
            break;
          default:
            resp = response.json();
        }

        if (resp && resp.error) {
          console.log("why are we here?");
        }
      return resp;
    })
開發者ID:chipster,項目名稱:chipster-web,代碼行數:25,代碼來源:rest.service.ts

示例2: FileReader

 conn.response.subscribe((res: ngResponse) => {
   let reader: FileReader = new FileReader();
   reader.addEventListener('loadend', function() {
     expect(reader.result).toBe(RESPONSE_BODY);
     done();
   });
   reader.readAsText(res.blob());
 });
開發者ID:wdupuy,項目名稱:newzr2,代碼行數:8,代碼來源:fetch_backend.spec.ts

示例3: Blob

 this.documentService.obtainReport(this.document).subscribe((res: Response) => {
   const contentDisposition = res.headers.get('Content-Disposition');
   let filename = this.document.documentId + '.pdf';
   if (contentDisposition) {
     filename = res.headers.get('Content-Disposition').match(/filename=(.*)/)[1];
   }
   const file = new Blob([res.blob()], { type: res.headers.get('Content-Type') });
   saveAs(file, filename);
 });
開發者ID:openfact,項目名稱:openfact-web-console,代碼行數:9,代碼來源:view-toolbar.component.ts

示例4:

			.then((response: Response) => {
				var contentType = response.headers.get("Content-Type");

				if (contentType.startsWith("image/")) {
					Urls.blobToDataUri(response.blob())
						.then((dataUri: string) => {
							this.data = dataUri;
							this.load.emit(this.data);
						});
				}
			},
開發者ID:deciare,項目名稱:flowerbox-web-angular,代碼行數:11,代碼來源:embed-media.component.ts

示例5: extractContent

 /**
  * Extract the File from Response context and download it
  * @param res Response
  */
 private static extractContent(res: Response, viewImage: boolean) {
   let blob: Blob = res.blob();
   let mainHead = res.headers.get('content-disposition');
   let filename = mainHead.split(';')
     .map(x => x.trim())
     .map(
       s => {
         if (s.split('=')[0] === 'filename') {
           return s.split('=')[1];
         }
       }
     ).filter(x => x)[0];
   let url = window.URL.createObjectURL(blob);
   if (viewImage) {
     return blob;
   } else {
     let a = document.createElement('a');
     a.href = url;
     a.download = typeof(filename) === 'string' ? filename : 'download';
     a.target = '_blank';
     a.click();
     a.remove();
   }
 }
開發者ID:HiP-App,項目名稱:HiP-CmsAngularApp,代碼行數:28,代碼來源:media.service.ts


注:本文中的@angular/http.Response.blob方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。