objective-c - 尝试列出 Firebase 存储桶中的文件时出现 NSInternalInconsistencyException
问题描述
我正在尝试使用以下代码获取我的 firebase 存储桶中所有对象的列表:
[listingReference listWithMaxResults:1000 completion:^(FIRStorageListResult * _Nonnull result, NSError * _Nullable error) {
if(error != nil){
NSLog(@"Error listing files");
NSLog(@"%@", error);
} else {
NSArray<FIRStorageReference *> *entries = result.prefixes;
NSArray<FIRStorageReference *> *entryItems = result.items;
NSLog(@"List folder complete");
NSLog(@"%@", entries);
NSLog(@"%@", entryItems);
}
}];
但是,当我运行代码时,出现以下错误:
由于未捕获的异常而终止应用程序:
NSInternalInconsistencyException',原因:'预期 gs://bucketname1/ 是 gs://bucketname1/testfile 的子元素
我listingReference
通过打印文件路径检查了我的文件路径,它输出gs://bucketname1/
了我认为正确的内容,因为我想列出存储桶中的所有文件。有什么我做错了吗?
解决方案
在我看来,您实际上无法查询存储桶中的所有文件,因此我在存储桶内创建了一个文件夹并将我的文件保存在该文件夹中,并且可以在那里查询它们。
推荐阅读
- php - 在负载均衡器上形成随机数?
- javascript - 堆的算法返回数组而不是打印
- powershell - TFS - 用于检查标准错误的 powershell 脚本
- html - 仅旋转按钮,而不是按钮单击时的文本
- android - 通过选定的信使发送文本
- php - Laravel 跨包的模型关系
- angular - 如何在 Typescript 中动态设置类的函数?
- android - 以编程方式将菜单操作栏图标背景颜色更改为不透明圆圈(不是整个工具栏)
- c++ - 不同的 C/C++ 库相互崩溃;可能干扰 poll() 和 select()?
- python - 在高级功能中访问低级功能选项的清晰方法?