Firebase Storage image uploads from Java don't show thumbnail preview in the Firebase console

て烟熏妆下的殇ゞ 提交于 2021-02-02 09:55:49

问题


i am trying to upload an image to firebase storage using java. The image is successfully uploaded but when you see it in the firebase it doesn't load ...

here is the code, is it correct?

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"));

this is the result on google firebase, the image never loads


回答1:


It's a known issue that image previews don't display in the Firebase console when uploading from backend code. It works fine if the file was uploaded from a Firebase client app. It might also work if you have a Firebase client request a download URL, which would create the URL necessary for the preview.

I suggest filing a bug report with Firebase support. This is a common request.



来源:https://stackoverflow.com/questions/62614014/firebase-storage-image-uploads-from-java-dont-show-thumbnail-preview-in-the-fir

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!