本文整理汇总了TypeScript中firebase.storage函数的典型用法代码示例。如果您正苦于以下问题:TypeScript storage函数的具体用法?TypeScript storage怎么用?TypeScript storage使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了storage函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor() {
/**
* Here we create the references I told you about 2 seconds ago :P
*/
this.currentUser = firebase.auth().currentUser;
this.userProfile = firebase.database().ref('/userProfile');
this.profilePictureRef = firebase.storage().ref('/userProfile/');
}
示例2: constructor
constructor() {
this.currentUser = firebase.auth().currentUser.uid;
this.eventList = firebase.database().ref(`userProfile/${this.currentUser}/eventList`);
this.itemList = firebase.database().ref(`userProfile/${this.currentUser}/itemList`);
this.pubItems = firebase.database().ref('/pubItems');
this.messageRooms = firebase.database().ref('/messages')
this.messageList = firebase.database().ref('/messages/1/messageList');
this.profilePictureRef = firebase.storage().ref('/messageImgs/');
this.itemPictureRef = firebase.storage().ref('/itemImgs/');
this.pictureRef = firebase.storage().ref('/messageImgs/1/');
}
示例3:
Object.keys(animations).forEach(function (animKey) {
console.log(animations[animKey].name);
animations_library.push(animations[animKey].name);
firebase.storage().ref('jsonFiles').child(animations[animKey].name + '.json').getDownloadURL().then(function (downloadUrl) {
console.log(downloadUrl);
console.log(typeof(downloadUrl));
$('#anim_url').attr('value', downloadUrl);
gameInstance.SendMessage('RTClipEditor', 'LoadAnimFromUrl', downloadUrl);
});
});
示例4: removePost
removePost(deletePost: Blog){
let dbRef = firebase.database().ref('blogPosts/').child(deletePost.id).remove();
alert('post deleted');
let imageRef = firebase.storage().ref().child(`images/${deletePost.imgTitle}`)
.delete()
.then(function() {
alert(`${deletePost.imgTitle} was deleted from Storage`);
}).catch(function(error) {
alert(`Error - Unable to delete ${deletePost.imgTitle}`);
});
}
示例5: uuid
return this.afAuth.authState.first().flatMap((user) => {
const userUid = user.uid;
const filename = uuid();
const path = `${userUid}/${filename}`;
const storage = firebase.storage().ref(path);
const metadata: firebase.storage.UploadMetadata = contentType && { contentType };
const putPromise = file instanceof File
? storage.put(file, contentType)
: storage.putString(file, firebase.storage.StringFormat.RAW, metadata);
return Observable.fromPromise(putPromise);
});
示例6: fileChange
fileChange(event) {
var files = event.srcElement.files;
var file = files[0];
var storageUrl = 'images/';
var name = `img-${Date.now()}.jpg`;
var storageRef = firebase.storage().ref(storageUrl + name);
storageRef.put(file).then(function(snapshot) {
//get the download URL
console.log(snapshot.downloadURL)
localStorage.setItem("currFile",snapshot.downloadURL);
});
}
示例7: ajax
$form.validator().on('submit', (e: JQueryEventObject) => {
const is_valid = !e.isDefaultPrevented();
if (!is_valid) {
return;
}
e.preventDefault();
const file = e.target[3].files[0];
if (!file) {
const form_data = `${$($form).serialize()}`;
ajax(form_data);
return false;
}
$($form).find(':submit').attr('disabled', 'disabled');
const uploadTask = firebase.storage().ref().child(`media/${file.name}`).put(file, { contentType: file.type });
uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, (snapshot) => {
let progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
$($form).find(':submit').html(`Uploading... ${parseInt(progress, 10)}%`);
}, error => console.log(error), () => {
$($form).find(':submit').html(`Saving...`);
const form_data = `${$($form).serialize()}&downloadUrl=${uploadTask.snapshot.downloadURL}`;
ajax(form_data);
});
function ajax(data) {
$.ajax({
url: '/dashboard/create/promo',
method: 'post',
data: data
}).then(res => {
$($form).find(':submit').html(`Done`);
window.location.replace('/dashboard');
});
}
});
示例8: createPost
createPost(post: Blog){
let storageRef = firebase.storage().ref();
storageRef.child(`images/${post.imgTitle}`).putString(post.img, 'base64')
.then((snapshot) => {
let url = snapshot.metadata.downloadURLs[0];
let dbRef = firebase.database().ref('blogPosts/');
let newPost = dbRef.push();
newPost.set ({
title: post.title,
content: post.content,
imgTitle: post.imgTitle,
img: url,
id: newPost.key
});
})
.catch ((error)=>{
alert(`failed upload: ${error}`);
});
}
示例9: constructor
constructor() {
this.profilePicture = firebase.storage().ref('profilePic');
this.messages = firebase.database().ref('/messages');
this.pubItemList = firebase.database().ref('/pubItems');
this.currentUser = firebase.auth().currentUser;
this.itemList = firebase.database().ref(`/userProfile/${this.currentUser.uid}/itemList`);
this.userRooms = firebase.database().ref(`/userProfile/${this.currentUser.uid}/rooms`);
this.pubRooms = firebase.database().ref('/pubs');
this.userContactP = firebase.database().ref(`/userProfile/${this.currentUser.uid}/contactsPadd/`);
this.userContacts = firebase.database().ref(`/userProfile/${this.currentUser.uid}/contacts/`);
this.groupRoom = firebase.database().ref(`/userProfile/${this.currentUser.uid}/groupChat`);
this.groupChatInvi = firebase.database().ref(`/userProfile/${this.currentUser.uid}/groupChatInvitation`);
this.userProfile = firebase.database().ref('/userProfile');
}
示例10: getGoldScreenshotImageUrl
/** Get the firebase storage golden image folder url */
getGoldScreenshotImageUrl(filename: string): firebase.Promise<string> {
return firebase.storage().ref('goldens').child(filename).getDownloadURL();
}