本文整理汇总了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 = '';
});
});
}
示例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;
}
示例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);
});
示例4: referenciaCloudStorage
//Referencia del archivo
public referenciaCloudStorage(nombreArchivo: string) {
return this.storage.ref(nombreArchivo);
}
示例5: finalize
finalize(() => this.downloadURL = this.storage.ref(path).getDownloadURL() )