'ref.getData() (firebase storage) doesn't work

I try to load images from the firebase storage. I'm using flutter (2.8.1) web.

My import

import 'package:firebase_storage/firebase_storage.dart' as firebase_storage;

This is how I get the reference

final ref =
        firebase_storage.FirebaseStorage.instance.ref('Food/$name.jpeg');

This line which should give me the bytes doesn't work...

final data = await ref.getData();

but getting the url of the image works fine.

final url = await ref.getDownloadURL();

The error for ref.getData() looks as follows:

Error: XMLHttpRequest error.
    dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 906:28                get current
packages/http/src/browser_client.dart 69:22                                       <fn>
dart-sdk/lib/async/zone.dart 1687:54                                              runUnary
dart-sdk/lib/async/future_impl.dart 160:18                                        handleValue
dart-sdk/lib/async/future_impl.dart 767:44                                        handleValueCallback
dart-sdk/lib/async/future_impl.dart 796:13                                        _propagateToListeners
dart-sdk/lib/async/future_impl.dart 593:7                                         [_complete]
dart-sdk/lib/async/stream_pipe.dart 61:11                                         _cancelAndValue
dart-sdk/lib/async/stream.dart 1288:7                                             <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 334:14  _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 339:39  dcall
dart-sdk/lib/html/dart2js/html_dart2js.dart 37254:58                              <fn>


    at Object.createErrorWithStack (http://localhost:57324/dart_sdk.js:5076:12)
    at Object._rethrow (http://localhost:57324/dart_sdk.js:40477:16)
    at async._AsyncCallbackEntry.new.callback (http://localhost:57324/dart_sdk.js:40473:13)
    at Object._microtaskLoop (http://localhost:57324/dart_sdk.js:40330:13)
    at _startMicrotaskLoop (http://localhost:57324/dart_sdk.js:40336:13)
    at http://localhost:57324/dart_sdk.js:35811:9


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source