Flutter Firebase Storage not woriking: no default bucket
915
The solution was rather simple: I needed to add the storageBucket
in my FirebaseOptions
so my main
looks like this:
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: kIsWeb || Platform.isAndroid
? FirebaseOptions(
apiKey: "my-app-key",
appId: "my-app-id",
messagingSenderId: "my-messaging-sender-id",
projectId: "my-project-id",
storageBucket: "myapp.appspot.com",
)
: null,
);
runApp(
const App(),
);
}
Author by
Chris
Updated on January 03, 2023Comments
-
Chris over 1 year
I am trying to upload a
pdf-file
toFirebase-Storage
using this function:static Future<String> savePdf({ required Uint8List assetAsUint8List, required String fileName, required DocumentType documentType, }) async { String path = '${BackendService().keys.studs}/${AuthenticationService().currentUser?.uid}/${documentType.name}/$fileName'; await FirebaseStorage.instanceFor().ref(path).putData( assetAsUint8List, ); return FirebaseStorage.instance.ref(path).getDownloadURL(); }
but this fails with this
error
:Unhandled Exception: [firebase_storage/no-bucket] No default storage bucket could be found. Ensure you have correctly followed the Getting Started guide.
I
configure
my app like this inside mymain
:Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp( options: kIsWeb || Platform.isAndroid ? FirebaseOptions( apiKey: "my-api-key", appId: "my-app-id", messagingSenderId: "my-messaing-sender-id", projectId: "appflug", ) : null, ); runApp( const App(), ); }
It is actually working on iOS! But NOT on Android or Web...
I followed the documentation but it is simply not working... I coulnd't find anything helpful on this!
What am I missing here?
Let me know if you need any more info!