【发布时间】:2019-07-18 17:22:38
【问题描述】:
我有一个需要从 Firebase 存储下载的文件夹和文件名称的 Arrylist。
它抛出异常是因为某些文件夹和文件在 firebase storage 中不存在。 是否可以在不引发异常的情况下检测文件夹和文件?
JS 代码:
var parNum = 'S3DD4';
var sessionNum = '3333';
var storageInfoarr = ["Testing/Testing1.3gp", "Testing/Testing1.xlsx"];
for (i = 0 ; i< storageInfoarr.length; i++){
var starsRef = storageRef.child(parNum+'/'+sessionNum+'/'+storageInfoarr[i])
var urlString = starsRef.getDownloadURL().catch(function(error) {
switch (error.code) {
case 'storage/object_not_found': // <<< here you decide what to do when the file doesn't exist
// File doesn't exist
break;
case 'storage/unauthorized':
// User doesn't have permission to access the object
break;
case 'storage/canceled':
// User canceled the upload
break;
}
});
【问题讨论】:
标签: javascript firebase google-cloud-firestore google-cloud-functions firebase-storage