使用 Java rest API 从 firebase 存储中上传的文件获取 public 下载 URL
Get public download URL from uploaded file in firebase storage with Java rest API
我想从 firebase-admin sdk 为 java.
上传的文件 (Blob) 中下载 URL
我的代码:
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(...);
所以,通过这段代码,我可以在 firebase 存储中上传文件。
但是我不知道如何下载 URL..
我想得到 URL (https://firebasestorage.googleapis.com...)
但是方法blob.getMediaLink()
returns 我是私有的 URL (https://www.googleapis.com/download/storage...)
您可以创建 signed URL, which does essentially the same thing as the download URLs generated by Firebase client SDKs, using Blob.signUrl()。
我想从 firebase-admin sdk 为 java.
上传的文件 (Blob) 中下载 URL我的代码:
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(...);
所以,通过这段代码,我可以在 firebase 存储中上传文件。 但是我不知道如何下载 URL.. 我想得到 URL (https://firebasestorage.googleapis.com...)
但是方法blob.getMediaLink() returns 我是私有的 URL (https://www.googleapis.com/download/storage...)
您可以创建 signed URL, which does essentially the same thing as the download URLs generated by Firebase client SDKs, using Blob.signUrl()。