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


TypeScript AngularFireStorage.ref方法代碼示例

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


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

示例1: onImageChange

  onImageChange(event:any) {
    const image = event.target.files[0];
    const uploader = document.getElementById('uploader') as HTMLInputElement;
    const storageRef = this.storage.ref('images/' + Date.now() + image.name);
    const task = storageRef.put(image);

    task.snapshotChanges().subscribe((snapshot) => {
        document.getElementById('buttonFile').style.visibility = 'hidden';
        document.getElementById('uploader').style.visibility = 'visible';

        const percentage = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
        uploader.value = percentage.toString();
      },
      (err:any) => {
        document.getElementById('buttonFile').style.visibility = 'visible';
        document.getElementById('uploader').style.visibility = 'hidden';
        uploader.value = '0';
      },
      () => {
        uploader.value = '0';
        document.getElementById('buttonFile').style.visibility = 'visible';
        document.getElementById('uploader').style.visibility = 'hidden';
        this.draftMessage = task.task.snapshot.ref.name.substring(0, 13);
        this.draftImage = task.task.snapshot.ref.name.substring(0, 13);
        storageRef.getDownloadURL().subscribe(url => {
          this.draftImageDownloadURL = url;
          this.addMessage();
          event.target.value = '';
        });
      });
  }
開發者ID:PERRINN,項目名稱:client-web,代碼行數:31,代碼來源:chat.component.ts

示例2: uploadImage

  async uploadImage(file) {
   const filePath = Date.now() + '.jpg';
   const ref = this.storage.ref('upload').child(filePath);
   const image = await ref.putString(file, 'data_url', {
     contentType: 'image/jpg'
   });
   const url = await this.getImageUrl(image);
   return url;
 }
開發者ID:niawjunior,項目名稱:blog,代碼行數:9,代碼來源:upload-content.service.ts

示例3: it

 it('should resolve the task as a promise', (done) => {
   const data = { angular: "promise" };
   const blob = new Blob([JSON.stringify(data)], { type : 'application/json' });
   const ref = afStorage.ref('af.json');
   const task: AngularFireUploadTask = ref.put(blob);
   task.then(snap => { 
     expect(snap).toBeDefined(); 
     done();
   }).catch(done.fail);
 });
開發者ID:PaulD11,項目名稱:angularfire2,代碼行數:10,代碼來源:storage.spec.ts

示例4: referenciaCloudStorage

 //Referencia del archivo
 public referenciaCloudStorage(nombreArchivo: string) {
   return this.storage.ref(nombreArchivo);
 }
開發者ID:castcosme,項目名稱:LabWeb2019PracticasFinal,代碼行數:4,代碼來源:firebase-storage.service.ts

示例5: finalize

 finalize(() => this.downloadURL = this.storage.ref(path).getDownloadURL() )
開發者ID:geeksmarter,項目名稱:andrews.codes,代碼行數:1,代碼來源:upload-page.component.ts


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