Firebase 存储异常:用户无权访问此对象
Firebase Storage Exception: User does not have permission to access this object
将图片上传到 firebase 存储时出现以下错误。
插件版本:
image_picker: ^0.6.7+3
firebase_storage: ^3.1.6
permission_handler: ^5.0.1+1
Firebase 存储规则:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if false;
}
}
}
以及我在调试控制台中得到的完整错误:
E/StorageException( 9672): StorageException has occurred.
E/StorageException( 9672): User does not have permission to access this object.
E/StorageException( 9672): Code: -13021 HttpResult: 403
E/StorageException( 9672): The server has terminated the upload session
E/StorageException( 9672): java.io.IOException: The server has terminated the upload session
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.serverStateValid(com.google.firebase:firebase-storage@@17.0.0:340)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.shouldContinue(com.google.firebase:firebase-storage@@17.0.0:309)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:223)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask.lambda$getRunnable(com.google.firebase:firebase-storage@@17.0.0:1106)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask$$Lambda.run(com.google.firebase:firebase-storage@@17.0.0)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/StorageException( 9672): at java.lang.Thread.run(Thread.java:761)
E/StorageException( 9672): Caused by: java.io.IOException: { "error": { "code": 403, "message": "Permission denied." }}
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@17.0.0:455)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@17.0.0:435)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@17.0.0:426)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:280)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:294)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:70)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:62)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.sendWithRetry(com.google.firebase:firebase-storage@@17.0.0:476)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.beginResumableUpload(com.google.firebase:firebase-storage@@17.0.0:277)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:218)
E/StorageException( 9672): ... 5 more
E/StorageException( 9672): StorageException has occurred.
E/StorageException( 9672): User does not have permission to access this object.
E/StorageException( 9672): Code: -13021 HttpResult: 403
E/StorageException( 9672): The server has terminated the upload session
E/StorageException( 9672): java.io.IOException: The server has terminated the upload session
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.serverStateValid(com.google.firebase:firebase-storage@@17.0.0:340)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.shouldContinue(com.google.firebase:firebase-storage@@17.0.0:309)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:223)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask.lambda$getRunnable(com.google.firebase:firebase-storage@@17.0.0:1106)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask$$Lambda.run(com.google.firebase:firebase-storage@@17.0.0)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/StorageException( 9672): at java.lang.Thread.run(Thread.java:761)
E/StorageException( 9672): Caused by: java.io.IOException: { "error": { "code": 403, "message": "Permission denied." }}
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@17.0.0:455)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@17.0.0:435)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@17.0.0:426)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:280)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:294)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:70)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:62)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.sendWithRetry(com.google.firebase:firebase-storage@@17.0.0:476)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.beginResumableUpload(com.google.firebase:firebase-storage@@17.0.0:277)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:218)
E/StorageException( 9672): ... 5 more
E/StorageException( 9672): StorageException has occurred.
E/StorageException( 9672): User does not have permission to access this object.
E/StorageException( 9672): Code: -13021 HttpResult: 403
E/StorageException( 9672): The server has terminated the upload session
E/StorageException( 9672): java.io.IOException: The server has terminated the upload session
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.serverStateValid(com.google.firebase:firebase-storage@@17.0.0:340)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.shouldContinue(com.google.firebase:firebase-storage@@17.0.0:309)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:223)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask.lambda$getRunnable(com.google.firebase:firebase-storage@@17.0.0:1106)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask$$Lambda.run(com.google.firebase:firebase-storage@@17.0.0)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/StorageException( 9672): at java.lang.Thread.run(Thread.java:761)
E/StorageException( 9672): Caused by: java.io.IOException: { "error": { "code": 403, "message": "Permission denied." }}
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@17.0.0:455)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@17.0.0:435)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@17.0.0:426)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:280)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:294)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:70)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:62)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.sendWithRetry(com.google.firebase:firebase-storage@@17.0.0:476)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.beginResumableUpload(com.google.firebase:firebase-storage@@17.0.0:277)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:218)
E/StorageException( 9672): ... 5 more
E/StorageException( 9672): StorageException has occurred.
E/StorageException( 9672): User does not have permission to access this object.
E/StorageException( 9672): Code: -13021 HttpResult: 403
E/StorageException( 9672): The server has terminated the upload session
E/StorageException( 9672): java.io.IOException: The server has terminated the upload session
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.serverStateValid(com.google.firebase:firebase-storage@@17.0.0:340)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.shouldContinue(com.google.firebase:firebase-storage@@17.0.0:309)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:223)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask.lambda$getRunnable(com.google.firebase:firebase-storage@@17.0.0:1106)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask$$Lambda.run(com.google.firebase:firebase-storage@@17.0.0)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/StorageException( 9672): at java.lang.Thread.run(Thread.java:761)
E/StorageException( 9672): Caused by: java.io.IOException: { "error": { "code": 403, "message": "Permission denied." }}
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@17.0.0:455)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@17.0.0:435)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@17.0.0:426)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:280)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:294)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:70)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:62)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.sendWithRetry(com.google.firebase:firebase-storage@@17.0.0:476)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.beginResumableUpload(com.google.firebase:firebase-storage@@17.0.0:277)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:218)
E/StorageException( 9672): ... 5 more
E/StorageException( 9672): StorageException has occurred.
E/StorageException( 9672): User does not have permission to access this object.
E/StorageException( 9672): Code: -13021 HttpResult: 403
E/StorageException( 9672): { "error": { "code": 403, "message": "Permission denied." }}
E/StorageException( 9672): java.io.IOException: { "error": { "code": 403, "message": "Permission denied." }}
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@17.0.0:455)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@17.0.0:435)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@17.0.0:426)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:280)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:294)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:70)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:62)
E/StorageException( 9672): at com.google.firebase.storage.GetDownloadUrlTask.run(com.google.firebase:firebase-storage@@17.0.0:74)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/StorageException( 9672): at java.lang.Thread.run(Thread.java:761)
E/flutter ( 9672): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(download_error, User does not have permission to access this object., null, null)
E/flutter ( 9672): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter ( 9672): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter ( 9672): <asynchronous suspension>
E/flutter ( 9672): #2 StorageReference.getDownloadURL (package:firebase_storage/src/storage_reference.dart:142:12)
E/flutter ( 9672): <asynchronous suspension>
E/flutter ( 9672): #3 FirebaseStorageService.uploadProductImage (package:farmers_market/src/services/firebase_storage_service.dart:14:12)
E/flutter ( 9672): <asynchronous suspension>
E/flutter ( 9672): #4 ProductBloc.pickImage (package:farmers_market/src/blocs/product_bloc.dart:95:24)
E/flutter ( 9672): <asynchronous suspension>
E/flutter ( 9672):
和一段代码
PickedFile image;
await Permission.photos.request();
var permissionStatus = await Permission.photos.status;
if (permissionStatus.isGranted) {
image = await _picker.getImage(source: ImageSource.gallery);
if (image != null) {
var imageUrl = await storageService.uploadProductImage(
File(image.path), uuid.v4());
changeImageUrl(imageUrl)
} else {
print('No Path Received');
}
} else {
print('Grant Permissions and try again');
}
之前我已经成功认证了firebase服务。我使用 Android 和模拟器来制作它。我错过了什么?
在您的 Firebase 规则中,
allow read, write: if false;
表示无法在您的数据库上读取或写入。您可以将其更改为 if true
以测试这是否是您问题的原因,然后使用更准确的规则。
见
将图片上传到 firebase 存储时出现以下错误。
插件版本:
image_picker: ^0.6.7+3
firebase_storage: ^3.1.6
permission_handler: ^5.0.1+1
Firebase 存储规则:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if false;
}
}
}
以及我在调试控制台中得到的完整错误:
E/StorageException( 9672): StorageException has occurred.
E/StorageException( 9672): User does not have permission to access this object.
E/StorageException( 9672): Code: -13021 HttpResult: 403
E/StorageException( 9672): The server has terminated the upload session
E/StorageException( 9672): java.io.IOException: The server has terminated the upload session
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.serverStateValid(com.google.firebase:firebase-storage@@17.0.0:340)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.shouldContinue(com.google.firebase:firebase-storage@@17.0.0:309)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:223)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask.lambda$getRunnable(com.google.firebase:firebase-storage@@17.0.0:1106)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask$$Lambda.run(com.google.firebase:firebase-storage@@17.0.0)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/StorageException( 9672): at java.lang.Thread.run(Thread.java:761)
E/StorageException( 9672): Caused by: java.io.IOException: { "error": { "code": 403, "message": "Permission denied." }}
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@17.0.0:455)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@17.0.0:435)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@17.0.0:426)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:280)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:294)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:70)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:62)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.sendWithRetry(com.google.firebase:firebase-storage@@17.0.0:476)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.beginResumableUpload(com.google.firebase:firebase-storage@@17.0.0:277)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:218)
E/StorageException( 9672): ... 5 more
E/StorageException( 9672): StorageException has occurred.
E/StorageException( 9672): User does not have permission to access this object.
E/StorageException( 9672): Code: -13021 HttpResult: 403
E/StorageException( 9672): The server has terminated the upload session
E/StorageException( 9672): java.io.IOException: The server has terminated the upload session
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.serverStateValid(com.google.firebase:firebase-storage@@17.0.0:340)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.shouldContinue(com.google.firebase:firebase-storage@@17.0.0:309)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:223)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask.lambda$getRunnable(com.google.firebase:firebase-storage@@17.0.0:1106)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask$$Lambda.run(com.google.firebase:firebase-storage@@17.0.0)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/StorageException( 9672): at java.lang.Thread.run(Thread.java:761)
E/StorageException( 9672): Caused by: java.io.IOException: { "error": { "code": 403, "message": "Permission denied." }}
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@17.0.0:455)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@17.0.0:435)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@17.0.0:426)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:280)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:294)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:70)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:62)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.sendWithRetry(com.google.firebase:firebase-storage@@17.0.0:476)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.beginResumableUpload(com.google.firebase:firebase-storage@@17.0.0:277)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:218)
E/StorageException( 9672): ... 5 more
E/StorageException( 9672): StorageException has occurred.
E/StorageException( 9672): User does not have permission to access this object.
E/StorageException( 9672): Code: -13021 HttpResult: 403
E/StorageException( 9672): The server has terminated the upload session
E/StorageException( 9672): java.io.IOException: The server has terminated the upload session
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.serverStateValid(com.google.firebase:firebase-storage@@17.0.0:340)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.shouldContinue(com.google.firebase:firebase-storage@@17.0.0:309)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:223)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask.lambda$getRunnable(com.google.firebase:firebase-storage@@17.0.0:1106)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask$$Lambda.run(com.google.firebase:firebase-storage@@17.0.0)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/StorageException( 9672): at java.lang.Thread.run(Thread.java:761)
E/StorageException( 9672): Caused by: java.io.IOException: { "error": { "code": 403, "message": "Permission denied." }}
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@17.0.0:455)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@17.0.0:435)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@17.0.0:426)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:280)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:294)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:70)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:62)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.sendWithRetry(com.google.firebase:firebase-storage@@17.0.0:476)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.beginResumableUpload(com.google.firebase:firebase-storage@@17.0.0:277)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:218)
E/StorageException( 9672): ... 5 more
E/StorageException( 9672): StorageException has occurred.
E/StorageException( 9672): User does not have permission to access this object.
E/StorageException( 9672): Code: -13021 HttpResult: 403
E/StorageException( 9672): The server has terminated the upload session
E/StorageException( 9672): java.io.IOException: The server has terminated the upload session
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.serverStateValid(com.google.firebase:firebase-storage@@17.0.0:340)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.shouldContinue(com.google.firebase:firebase-storage@@17.0.0:309)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:223)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask.lambda$getRunnable(com.google.firebase:firebase-storage@@17.0.0:1106)
E/StorageException( 9672): at com.google.firebase.storage.StorageTask$$Lambda.run(com.google.firebase:firebase-storage@@17.0.0)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/StorageException( 9672): at java.lang.Thread.run(Thread.java:761)
E/StorageException( 9672): Caused by: java.io.IOException: { "error": { "code": 403, "message": "Permission denied." }}
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@17.0.0:455)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@17.0.0:435)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@17.0.0:426)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:280)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:294)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:70)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:62)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.sendWithRetry(com.google.firebase:firebase-storage@@17.0.0:476)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.beginResumableUpload(com.google.firebase:firebase-storage@@17.0.0:277)
E/StorageException( 9672): at com.google.firebase.storage.UploadTask.run(com.google.firebase:firebase-storage@@17.0.0:218)
E/StorageException( 9672): ... 5 more
E/StorageException( 9672): StorageException has occurred.
E/StorageException( 9672): User does not have permission to access this object.
E/StorageException( 9672): Code: -13021 HttpResult: 403
E/StorageException( 9672): { "error": { "code": 403, "message": "Permission denied." }}
E/StorageException( 9672): java.io.IOException: { "error": { "code": 403, "message": "Permission denied." }}
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@17.0.0:455)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@17.0.0:435)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@17.0.0:426)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:280)
E/StorageException( 9672): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:294)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:70)
E/StorageException( 9672): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:62)
E/StorageException( 9672): at com.google.firebase.storage.GetDownloadUrlTask.run(com.google.firebase:firebase-storage@@17.0.0:74)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
E/StorageException( 9672): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
E/StorageException( 9672): at java.lang.Thread.run(Thread.java:761)
E/flutter ( 9672): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(download_error, User does not have permission to access this object., null, null)
E/flutter ( 9672): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter ( 9672): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter ( 9672): <asynchronous suspension>
E/flutter ( 9672): #2 StorageReference.getDownloadURL (package:firebase_storage/src/storage_reference.dart:142:12)
E/flutter ( 9672): <asynchronous suspension>
E/flutter ( 9672): #3 FirebaseStorageService.uploadProductImage (package:farmers_market/src/services/firebase_storage_service.dart:14:12)
E/flutter ( 9672): <asynchronous suspension>
E/flutter ( 9672): #4 ProductBloc.pickImage (package:farmers_market/src/blocs/product_bloc.dart:95:24)
E/flutter ( 9672): <asynchronous suspension>
E/flutter ( 9672):
和一段代码
PickedFile image;
await Permission.photos.request();
var permissionStatus = await Permission.photos.status;
if (permissionStatus.isGranted) {
image = await _picker.getImage(source: ImageSource.gallery);
if (image != null) {
var imageUrl = await storageService.uploadProductImage(
File(image.path), uuid.v4());
changeImageUrl(imageUrl)
} else {
print('No Path Received');
}
} else {
print('Grant Permissions and try again');
}
之前我已经成功认证了firebase服务。我使用 Android 和模拟器来制作它。我错过了什么?
在您的 Firebase 规则中,
allow read, write: if false;
表示无法在您的数据库上读取或写入。您可以将其更改为 if true
以测试这是否是您问题的原因,然后使用更准确的规则。
见