本文整理汇总了TypeScript中firebase/app.storage函数的典型用法代码示例。如果您正苦于以下问题:TypeScript storage函数的具体用法?TypeScript storage怎么用?TypeScript storage使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了storage函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: deleteImageRef
deleteImageRef() {
let storage = firebase.storage();
let imageRef = storage.refFromURL(this.imageUrl);
let me = this;
imageRef.delete().then(function() {
me.imageUrl = null;
}).catch(function(error) {
console.log('error', error);
});
}
示例2: uploadImage
uploadImage() {
let storageRef = firebase.storage().ref();
let path = Date.now().toString() + '-' + this.file.name;
let iRef = storageRef.child('posts/' + path);
let me = this;
iRef.put(this.file).then((snapshot) => {
let snackBarRef = this.snackBar.open('Image uploaded', 'OK!', {
duration: 3000
});
this.storageRef.child('posts/' + path).getDownloadURL().then(function(url) {
me.imageUrl = url;
me.newThumbnail = url;
});
});
}
示例3: Promise
return new Promise((resolve, reject) => {
firebase.storage()
.ref(ref)
.getDownloadURL()
.then((url) => {
resolve(url);
}).catch((error) => {
switch (error.code) {
case "storage/object_not_found":
reject("File doesn't exist");
break;
case "storage/unauthorized":
reject("User doesn't have permission to access the object");
break;
case "storage/canceled":
reject("User canceled the upload");
break;
case "storage/unknown":
reject("Unknown error occurred");
break;
}
});
});