#[SOLVED] How to get the URL of a file from the Storage Bucket

17 messages · Page 1 of 1 (latest)

smoky pelican
#

I'm developing an Android app using Kotlin and Appwrite.
I want to get the URL of the file so that I can download it. Is there any method to achieve that?
The code below return a ByteArray. I want to get the URL of the file.

                    bucketId = "660fd3e8a1341d1deb24",
                    fileId = "669a37030001cf108f01"
                )```
What can be solution to this apart from manually building the link?
round trout
eternal wing
#

use the storage.getFileView to get a viewable url. also dependent on the permissions you'd have set.

smoky pelican
smoky pelican
smoky pelican
round trout
#

With it being a public file, you should be able to use a URL like this to get the file https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files/{fileId}/preview?project={projectId}

smoky pelican
eternal wing
round trout
eternal wing
smoky pelican
#

Ok got it!

#

Thanks a lot guys

eternal wing
#

I think this behaviour needs to change though, for the sake of consistency imo. Different SDKs, different return values isn't really good. @round trout wdyt?

round trout
drifting pilot
#

You can do somthing like this val url = "{Config.ENDPOINT}/storage/buckets/$BUCKET_ID/files/$id/view?project=${Config.PROJECT}"
Where Id is the image id in yor storage