【发布时间】:2021-07-28 05:49:39
【问题描述】:
我安装了 Resize Images 扩展程序并且它正在工作。 在我的应用中,我有:
const storageRef = firebase.storage().ref();
const imagesRef = storageRef.child(`users/${user?.id}/images`);
const imageRef = imagesRef.child(`${timestamp}.jpg`);
imageRef.put(blob).then((snapshot) => {
snapshot.ref
.getDownloadURL()
.then((image_url) => {
返回的image_url 是上传的原始图片,而不是调整大小的图片。
如何获取调整后图片的下载地址?
我尝试将此添加到响应中:
imagesRef
.child(`${timestamp}_1000x1000.jpg`)
.getDownloadURL()
.then((resized_image_url) => {
console.log('resized_image_url', resized_image_url);
});
但它当然不能工作,因为我们不知道压缩图像何时准备好。 显然,在我得到成功响应之前进行某种延迟循环是浪费的。
我在想的一件事(但不喜欢作为一种解决方法)是,由于我在成功调整大小时删除了原始图像,也许我可以以某种方式收听它,当删除时,按照我上面的建议获取调整大小的图像?
那我该怎么办?
【问题讨论】:
标签: firebase google-cloud-firestore firebase-extensions