我有一个初始函数,当我的应用程序启动并尝试将实际图像上传到存储设备时会触发。我也尝试过串,但是没有运气。
Js:
let fileName;
let storageRef;
const imageFile = "./images/200.jpg"
//const imageUpload = storage.ref(`images/${imageFile.name}`).putString(imageFile)
fileName = '200.jpg';
storageRef = storage.ref(`images/${fileName}`);
const imageUpload = storageRef.put(imageFile);
imageUpload.on(
'state_changed',
(snapshot) => {
//process fun here
console.log(snapshot);
},
(error) => {
//error fun here
console.log(error);
},
() => {
storage
.ref('images')
.child(imageFile.name)
.getDownloadURL()
.then((url) => {
console.log(url);
});
}
);