我的颤音应用程序有一个下载功能,显示从防火墙存储的pdf和下载按钮下载文件。视图pdf功能运行良好。但是,下载pdf会引发异常。
W/StorageUtil( 5624): no auth token for request
D/EGL_emulation( 5624): app_time_stats: avg=107.69ms min=6.46ms max=1118.11ms count=13
W/StorageUtil( 5624): Error getting App Check token; using placeholder token instead. Error: com.google.firebase.FirebaseException: Too many attempts.
E/StorageException( 5624): An unknown error occurred, please check the HTTP result code and inner exception for server response.
E/StorageException( 5624): User does not have permission to access this object.
E/StorageException( 5624): Code: -13021 HttpResult: 403
E/StorageException( 5624): { "error": { "code": 403, "message": "Permission denied." }}有关该应用的详细信息:-
match /documents/{docId}{allow read,write;}我试图下载该文件的示例代码是
Future<void> downloadFile(String downloadUrl, String filename) async {
Directory appDocDir = await getApplicationDocumentsDirectory();
File downloadToFile = File('${appDocDir.path}/$filename');
try {
var url = await firebase_storage.FirebaseStorage.instance
.ref('documents/$filename')
.storage
.ref();
await url.writeToFile(downloadToFile);
} on firebase_core.FirebaseException catch (e) {
print('Exception' + e);
}
}我已经更新了所有的包&依赖关系,但都是徒劳的。我肯定我遗漏了什么。伸出援助之手,我们将不胜感激。
发布于 2022-05-18 06:20:58
尝试:
final isRef = await firebase_storage.FirebaseStorage.instance
.ref().child("'documents/$filename'");
Directory appDocDir = await getApplicationDocumentsDirectory();
File downloadToFile = File('${appDocDir.path}/$filename');
final downloadTask = isRef.writeToFile(downloadToFile);https://stackoverflow.com/questions/72283704
复制相似问题