请为您的Firebase存储桶使用gs://网址

问题描述 投票:0回答:1

我有一个连接到多个Firebase项目的项目。我可以访问第一个Firebase项目存储,我可以访问第二个Firebase项目数据库,但是不能访问第二个Firebase项目存储。这是我的代码:

private void configureFirebase(String projectID, String applicationID, String APIkey, String databaseURL, String storageBucket) {
    FirebaseOptions options = new FirebaseOptions.Builder()
            .setProjectId(projectID)
            .setApplicationId(applicationID)
            .setApiKey(APIkey)
            .setDatabaseUrl(databaseURL)
            .setStorageBucket("gs://myProjectID.appspot.com")
            .build();

    try {
        FirebaseApp.initializeApp(context, options, "secondary");
    } catch (Exception e) {
        Log.d("Exception",e.toString());
    }

    FirebaseApp secondary = FirebaseApp.getInstance("secondary");
    FirebaseDatabase otherDatabase = FirebaseDatabase.getInstance(secondary);

    databaseReference = otherDatabase.getReference();

    FirebaseStorage storage = FirebaseStorage.getInstance("secondary");
    storageRef = storage.getReferenceFromUrl(storageBucket);

    saveBucketUrl(storageBucket);
}

这是我得到的错误:

Please use a gs:// URL for your Firebase Storage bucket

即使我有适当的存储URL,也无法正常工作。

android firebase firebase-storage
1个回答
0
投票

出于通过Firebase SDK进行初始化的目的,您实际上应该从存储桶名称中删除“ gs://”。

setStorageBucket("myProjectID.appspot.com")
© www.soinside.com 2019 - 2024. All rights reserved.