gpt4 book ai didi

firebase_storage object-not-found 在所需的引用 flutter 中不存在任何对象

转载 作者:行者123 更新时间:2023-12-04 13:29:18 25 4
gpt4 key购买 nike

重要 : 我发现了同样的问题,但由于调试信息不​​完整而关闭。
我正在将图像上传到 firebase 存储,然后获取该图像的下载 URL 并将其存储到 firebase,以便我可以使用该 URL 使用网络图像显示用户的个人资料图像。
在我存储图像之前它工作正常

Reference storageRef = FirebaseStorage.instance.ref('images');
file = await _compressImage(file: file,);
await storageRef.putFile(file);
final String downloadUrl = await storageRef.child(id).getDownloadURL();
return downloadUrl;

但是在我将图像存储在特定文件夹中之后
Reference storageRef = FirebaseStorage.instance.ref('images');
file = await _compressImage(file: file, id: id);
await storageRef
.child(Get.find<UserController>().user.username)
.child(id)
.putFile(file);
final String downloadUrl = await storageRef.child(id).getDownloadURL();
return downloadUrl;

它显示此错误。
 [firebase_storage/object-not-found] No object exists at the desired reference.
这是可解释的代码:
我将可下载的 URL 存储在 newImage 变量中
 String newImage;
if (_controller.file != null) {
newImage = await Database().uploadFile(
file: _controller.file,
id: Get.find<UserController>().user.username);
print("new image: " + newImage.toString());
}
但是在这里,当我打印 newImage 的值时,它将 null 打印到控制台。
new image: null
这是将图像上传到 firebase 存储的第二种方法。
Future<String> uploadFile({@required File file, @required String id}) async {
try {
file = await _compressImage(file: file, id: id);
await storageRef
.child(Get.find<UserController>().user.username)
.child(id)
.putFile(file);
final String downloadUrl = await storageRef.child(id).getDownloadURL();
return downloadUrl;
} catch (e) {
print(e);
}
}
调试控制台:
E/StorageException(11376): StorageException has occurred.
E/StorageException(11376): Object does not exist at location.
E/StorageException(11376): Code: -13010 HttpResult: 404
E/StorageException(11376): { "error": { "code": 404, "message": "Not Found. Could not get object", "status": "GET_OBJECT" }}
E/StorageException(11376): java.io.IOException: { "error": { "code": 404, "message": "Not Found. Could not get object", "status": "GET_OBJECT" }}
E/StorageException(11376): at com.google.firebase.storage.network.NetworkRequest.parseResponse(NetworkRequest.java:434)
E/StorageException(11376): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(NetworkRequest.java:451)
E/StorageException(11376): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(NetworkRequest.java:442)
E/StorageException(11376): at com.google.firebase.storage.network.NetworkRequest.performRequest(NetworkRequest.java:272)
E/StorageException(11376): at com.google.firebase.storage.network.NetworkRequest.performRequest(NetworkRequest.java:286)
E/StorageException(11376): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(ExponentialBackoffSender.java:70)
E/StorageException(11376): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(ExponentialBackoffSender.java:62)
E/StorageException(11376): at com.google.firebase.storage.GetDownloadUrlTask.run(GetDownloadUrlTask.java:76)
E/StorageException(11376): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
E/StorageException(11376): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
E/StorageException(11376): at java.lang.Thread.run(Thread.java:764)
I/flutter (11376): [firebase_storage/object-not-found] No object exists at the desired reference.
I/flutter (11376): new image: null
但是当我检查 firebase 存储并且图像在那里成功上传时。
我所知道的是,图像已成功上传到 firebase 存储,但上述方法在上传图像之前以某种方式返回了一个可关闭的 URL。

最佳答案

我因为与您和 IDK 相同的问题而损失了很多时间,但它是通过在使用之前创建引用来工作的:

    final FirebaseStorage feedStorage =
FirebaseStorage.instanceFor(bucket: F.feedBucket);

Reference refFeedBucket = feedStorage
.ref()
.child('venues')
.child(auth.user.uid)
.child('vibes')
.child(p.basename(file.path));

String downloadUrl;

TaskSnapshot uploadedFile = await refFeedBucket.putFile(file);

if (uploadedFile.state == TaskState.success) {
downloadUrl = await refFeedBucket.getDownloadURL();
}

return downloadUrl;

关于firebase_storage object-not-found 在所需的引用 flutter 中不存在任何对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66068063/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com