问题
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