Get public download URL from uploaded file in fire

2019-08-18 17:22发布

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条回答
够拽才男人
2楼-- · 2019-08-18 17:55

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

查看更多
登录 后发表回答