如何以编程方式生成动态链接到Firebase中的存储对象? [英] How to programatically generate a Dynamic Link to a Storage Object in Firebase?

查看:150
本文介绍了如何以编程方式生成动态链接到Firebase中的存储对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google IO 2016推出的Firebase新版本引入了Firebase动态链接(作为深层链接概念的扩展)以及Firebase存储(由Google云端存储提供支持)。

如何以编程方式生成Firebase动态链接到Firebase存储对象?

编辑1



据我所知,我们可以使用以下代码获取包含存储对象的Google Cloud Storage存储桶和存储桶中对象的完整路径

  public String getDynamicLink(StorageReference storageReference)
{
String dynamicLink =;

String bucket = storageReference.getBucket();
String path = storageReference.getPath();

//如何使用存储桶和路径生成动态链接?
返回dynamicLink;

编辑2



按照 https://cloud.google.com/ storage / docs / collaboration#browser ,您可以使用以下语法构建Google云端存储对象的网址:

  https://storage.cloud.google.com/<bucket>/<object> 

如何以编程方式生成动态链接?

解决方案

最后得到它 使用存储桶名称和存储对象路径生成谷歌云存储对象的网址,在问题的编辑中提到。

然后创建一个动态链接以编程方式通过构建一个具有以下形式的URL:

  https:// domain /?link = your_deep_link& apn = package_name [& amv = minimum_version] [& ad = 1] [& android_link] [& afl = fallback_link] 

请参阅
https://firebase.google.com/docs/dynamic-links/android #create-a-dynamic-link-programmatically 了解更多详情。


The new version of Firebase introduced in Google IO 2016 has introduced Firebase Dynamic Links (as an extension of the deep linking concept) as well as Firebase Storage (powered by Google Cloud Storage).

How can programatically generate a Firebase Dynamic Link to a Firebase Storage Object?

EDIT-1

I understand that we can get the Google Cloud Storage bucket that holds a Storage object and the full path to the object in the Storage bucket using the following code

public String getDynamicLink(StorageReference storageReference)
{
    String dynamicLink = "";

    String bucket = storageReference.getBucket();
    String path = storageReference.getPath();

    // How to generate dynamic link using the bucket and path?
    return dynamicLink;
}

Edit-2

As per https://cloud.google.com/storage/docs/collaboration#browser, you can construct a URL to a Google Cloud Storage object using the following syntax:

https://storage.cloud.google.com/<bucket>/<object>

How to programatically generate dynamic link using this?

解决方案

Finally got it

Use the bucket name and storage object path to generate the google cloud storage object url as mentioned in the edits in the question.

Then create a Dynamic Link programmatically by constructing a URL with the following form:

https://domain/?link=your_deep_link&apn=package_name[&amv=minimum_version][&ad=1][&al=android_link][&afl=fallback_link]

Please see https://firebase.google.com/docs/dynamic-links/android#create-a-dynamic-link-programmatically for further details.

这篇关于如何以编程方式生成动态链接到Firebase中的存储对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆