【发布时间】:2019-04-10 12:07:24
【问题描述】:
我正在尝试将 n 张照片上传到 Firebase 存储并将这些 URL 保存在 Firestore 内的数组中,但我无法获得 downloadURL() 或者我不知道在哪里可以找到它。我检查了其他答案,但那些是针对单个文件的,我正在尝试上传一批并将 URL 存储在一起,而不是上传并将 URL 存储到 Firestore 等等......
代码:
_uploadImages(String userID, String productID, List<File> images, Function onSuccess(List<String> imageURLs), Function onFailure(String e)) {
List<String> imageURLs = [];
int uploadCount = 0;
StorageReference storeRef = FirebaseStorage.instance.ref().child('Products').child(userID).child(productID).child(uploadCount);
StorageMetadata metaData = StorageMetadata(contentType: 'image/png');
images.forEach((image) {
storeRef.putFile(image, metaData).onComplete.then((snapshot) {
STUCK AT THIS POINT SINCE THE SNAPSHOT DOESN'T SHOW THE URL OPTION...
//imageURLs.add(snapshot. )
uploadCount++;
if (uploadCount == images.length) {
onSuccess(imageURLs);
}
});
});
}
【问题讨论】:
标签: firebase dart flutter google-cloud-firestore firebase-storage