简体   繁体   English

如何在 Java Spring 上的 firebase 存储中获取上传文件的下载 URL

[英]How to get downloadURL of uploaded file in firebase storage on Java Spring Boot

In Java Spring boot, I can get the signed url using firebase-admin sdk.在 Java Spring 引导中,我可以使用 firebase-admin ZEAE18BC41E1434DA8Z82Z 获得签名的 url。

Bucket bucket = StorageClient.getInstance().bucket();
Storage storage = bucket.getStorage();
BlobInfo blobInfo = BlobInfo.newBuilder(bucket.getName(), storeFileName)
                .setContentType(fileType).build();
URL url = storage.signUrl(blobInfo, 5, TimeUnit.DAYS, Storage.SignUrlOption.withV4Signature());
                String signedPath = url.toString();

But I need to get the downloadUrl instead of signed url in the Java Spring Boot like the following flutter code.但是我需要在 Java Spring 中获取 downloadUrl 而不是签名的 url

// Flutter Code
Reference ref = FirebaseStorage.instance.ref().child(storePath);
String url = (await ref.getDownloadURL()).toString();

I can't add the Firebase-Storage sdk in Java Spring, Only Mobile possible.我无法在 Java Spring 中添加 Firebase-Storage sdk,只能使用移动设备。

https://mvnrepository.com/artifact/com.google.firebase/firebase-storage/11.0.2 https://mvnrepository.com/artifact/com.google.firebase/firebase-storage/11.0.2

The Admin SDKs for Cloud Storage are pretty thin wrappers around the GCP libraries for those platforms, which indeed don't provide a getDownloadURL method. Cloud Storage 的 Admin SDK 是这些平台的 GCP 库的非常薄的包装器,它们确实不提供getDownloadURL方法。

The closest equivalent that the GCP SDKs have is a so-called signed URL , which is similar to a download URL, but has an expiration timestamp. GCP SDK 最接近的等价物是所谓的签名 URL ,类似于下载 URL ,但有一个过期时间戳。

If that doesn't meet your needs, you can set a metadata property on the file to generate a download URL yourself as shown in this answer: Get Download URL from file uploaded with Cloud Functions for Firebase .如果这不能满足您的需求,您可以在文件上设置元数据属性以自己生成下载 URL,如以下答案所示: Get Download URL from file upload with Cloud Functions for Z035489FF8D0927141943

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用 Spring Boot 在 Firebase 存储上预览上传的图像 - Unable to preview uploaded image on firebase storage using spring boot 使用Java Rest API从Firebase存储中的上传文件中获取公共下载URL - Get public download URL from uploaded file in firebase storage with Java rest API 如何在Spring Surf Java Webscript中将文件上传到本地文件夹? - How to get uploaded file to local folder in spring surf java webscript? 如何在云存储上检查 Firebase 的上传文件的文件类型? - How to check the filetype of an uploaded file on Cloud Storage for Firebase? 如何在 Java Spring Boot MVC 中提供静态和上传的内容 - How to serve static and uploaded content in Java Spring Boot MVC 如何使用 Java 8 在 Spring Boot 中获取目录(不是文件)的完整系统路径 - How to get the full system path of a directory (not file) in Spring boot with Java 8 如何在 Java Spring Boot 中获取 zip 文件作为响应? - How to get zip file as an response in Java spring boot? Java Spring Boot 中的 Firebase 上传 - Firebase Upload in Java Spring Boot 如何使用 Java 中的 Firebase Admin 将文件上传到 Firebase 存储? - How to Upload file to Firebase Storage using Firebase Admin in Java? 如何获取本地开发服务器中Google云存储上载文件的公共链接(Google App Engine + JAVA) - How to get public link for the uploaded file on google cloud storage in local dev server(Google App engine+JAVA)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM