Chr*_*ris 6 dart google-cloud-storage firebase flutter firebase-storage
我正在尝试pdf-file使用Firebase-Storage此功能上传:
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();
}
Run Code Online (Sandbox Code Playgroud)
但这失败了error:
未处理的异常:[firebase_storage/no-bucket] 找不到默认存储桶。确保您已正确遵循入门指南。
我configure的应用程序在我的里面是这样的main:
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(),
);
}
Run Code Online (Sandbox Code Playgroud)
它实际上可以在 iOS 上运行!但不适用于 Android 或 Web...
我遵循了文档,但它根本不起作用......我找不到任何对此有帮助的东西!
我在这里缺少什么?
如果您需要更多信息,请告诉我!
Chr*_*ris 18
storageBucket解决方案相当简单:我需要在 my 中添加,FirebaseOptions所以我的main看起来像这样:
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(),
);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7664 次 |
| 最近记录: |