【发布时间】:2020-06-26 23:54:10
【问题描述】:
我在使用 Image_Picker 时尝试将图像上传到 Firebase 存储。
当我想将图片(imageFile)上传到 Firebase 存储时
Future uploadFile() async {
StorageReference storageReference =
storage.ref().child('profile/${Path.basename(imageFile.path)}}');
print('uploading..');
StorageUploadTask uploadTask = storageReference.putFile(imageFile);
//waiting for the image to upload
await uploadTask.onComplete;
print('File Uploaded');
storageReference.getDownloadURL().then((fileURL) {
setState(() {
imageURL = fileURL;
});
print(imageURL);
});
}
但是,在上传过程中,出现错误提示我没有身份验证令牌请求。 我之前使用 Firebase Auth 将数据存储到数据库中,并且所有内容都已正确配置(我假设是因为 Firebase 给了我一个 google.json 文件)。
W/NetworkRequest( 5796): no auth token for request
E/StorageUtil( 5796): error getting token java.util.concurrent.TimeoutException: Timed out waiting for Task
我还尝试将存储规则从 read, write if auth != null 更改为 read, write。
【问题讨论】:
标签: firebase flutter firebase-storage