【发布时间】:2019-05-16 07:22:27
【问题描述】:
我正在尝试使用 vue.js 将图像添加到 Firebase 存储
我的代码编译了我没有获得任何结果的方式
数据已添加到 Firestore 我想获取下载 URL 以及任何建议
methods: {
saveNewAticle() {
db
.collection("storys")
.add({
title: this.title,
summary: this.summary,
article: this.article
})
.then(docRef => {
console.log("Client added: ", docRef.id);
this.$router.push("/");
})
.catch(error => {
console.error("Error adding employee: ", error);
});
//links ref
//https://firebase.google.com/docs/storage/web/start
var storageref= storage.ref()
var thumbnailref = storageref.child ("images")
var file = thumbnail
var uploadTask = storageRef.child('images/${file}').put(file)
uploadTask
.on(firebase.storage.TaskEvent.STATE_CHANGED,
function(snapshot) {
// /Upload completed successfully, now we can get the download URL
uploadTask.snapshot.ref.getDownloadURL().then(function(downloadURL) {
console.log('File available at', downloadURL);
});
})
}
}
【问题讨论】:
标签: javascript firebase web vue.js firebase-storage