Back

[SOLVED]How to show multiple images all at once in respective to storage image id stored in database

  • 0
  • Databases
  • Storage
Dipen
29 May, 2023, 03:52

How can i show all the images that I have stored in Storage bucket -> id linked to the database table?

TL;DR
Solution: To show multiple images based on their respective image IDs stored in the database, you can use the following steps: 1. Replace "cloud.appwrite.io" with your Appwrite endpoint if you're using a self-hosted solution. 2. Use the "listDocuments" function to retrieve the list of products from the database. 3. Iterate over each product in a loop. 4. If you're using the cloud, construct the image URL as follows: - Replace B_ID with the Bucket ID. - Replace F_ID with the File ID. - Replace P_ID with the Project ID. - Use this URL
Dipen
29 May, 2023, 03:52

How to show multiple images all at once in respective to storage image id stored in database?

Binyamin
29 May, 2023, 03:53

You mean, you have an list of IDs of images, and you want to display all of them?

Dipen
29 May, 2023, 03:56

I have list of products where i have image id as an attribute to store the image id. Now i need to show all the products along with the respective images getting from storage bucket

Binyamin
29 May, 2023, 03:59

For the products you'll probably use the listDocuments function run a loop all over them.

As for each image are you using cloud or self hosted? If you're using the cloud then you can use a URL like this https://cloud.appwrite.io/v1/storage/buckets/B_ID/files/F_ID/preview?project=P_ID

When: B_ID = Bucket ID F_ID = File ID P_ID = Project ID

Inside an image src attribute

TypeScript
<img src="https://cloud.appwrite.io/v1/storage/buckets/B_ID/files/F_ID/preview?project=P_ID" >
Binyamin
29 May, 2023, 03:59

If you're using a self hosted just replace cloud.appwrite.io with your Appwrite endpoint.

Binyamin
29 May, 2023, 03:59

Is this make sense?

Dipen
29 May, 2023, 10:17

Thank you so much <:appwriterocket:823996226894692403>

Dipen
29 May, 2023, 10:18

[SOLVED]How to show multiple images all at once in respective to storage image id stored in database

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more