从Java上传的Firebase存储映像不会在Firebase控制台中显示缩略图预览

时间:2020-06-27 18:31:59

标签: java firebase file-upload firebase-storage firebase-admin

我正在尝试使用Java将图像上传到Firebase存储。图片已成功上传,但是当您在Firebase中看到该图片时,该图片无法加载...

这是代码,对吗?

FirebaseOptions options = FirebaseOptions.builder().setCredentials(
            GoogleCredentials.fromStream(getClass().getResourceAsStream("/credentials.json"))).setDatabaseUrl("https://myexample.firebaseio.com")
            .setStorageBucket("myexample-123456.appspot.com").build();

    FirebaseApp fireApp = FirebaseApp.initializeApp(options);

    StorageClient storageClient = StorageClient.getInstance(fireApp);
    InputStream   testFile      = new FileInputStream(userSelection); // userselection is the image path that the user chose
    String        blobString    = "ProfilePictures/" + "TEST.png";

    storageClient.bucket().create(blobString, testFile, "image/png", Bucket.BlobWriteOption.userProject("myexample-123456"));

这是Google Firebase上的结果,图像从不加载

1 个答案:

答案 0 :(得分:0)

这是一个已知问题,从后端代码上传时,图像预览不会显示在Firebase控制台中。如果文件是从Firebase客户端应用程序上传的,则效果很好。如果您有Firebase客户端请求下载URL,它可能会创建预览所需的URL,它也可能会起作用。

我建议使用Firebase support提交错误报告。这是一个常见的请求。