当前位置: 首页>>代码示例>>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;未经允许,请勿转载。