问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/37360664/how-to-programatically-generate-a-dynamic-link-to-a-storage-object-in-firebase