Get public download URL from uploaded file in firebase storage with Java rest API

邮差的信 提交于 2019-12-11 17:18:13

问题


I would like to get the download URL from a file (Blob) upload by firebase-admin sdk for java.

My Code:

    FirebaseOptions options = new FirebaseOptions.Builder()
            .setCredentials(GoogleCredentials.fromStream(serviceAccount))
            .setDatabaseUrl("...")
            .build();

        FirebaseApp app = FirebaseApp.initializeApp(options);
        StorageClient storage = StorageClient.getInstance(app);

        Bucket bucket = storage.bucket("...");

        Blob blob = bucket.create(...);

so, by this code I am able to upload file in firebase storage. But I dont know how to get the download URL.. I want to get the URL (https://firebasestorage.googleapis.com...)

But the method blob.getMediaLink() returns me the URL (https://www.googleapis.com/download/storage...) which is private


回答1:


You can create a signed URL, which does essentially the same thing as the download URLs generated by Firebase client SDKs, using Blob.signUrl().



来源:https://stackoverflow.com/questions/54393462/get-public-download-url-from-uploaded-file-in-firebase-storage-with-java-rest-ap

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