Back

When uploading a file to storage, is there a way to add a tag to the file?

  • 0
  • Web
  • Storage
bladmist
4 Sep, 2023, 18:52

I want to be able to add a tag of say "user X' to a file such that i can do a listfiles and only get the files with user X tag? I'm confused how to use permission to achieve this or do I just create different buckets?

TL;DR
There is a way to add a tag to a file when uploading it to storage. You can create a function that gets triggered on each file upload and update the collection with the necessary details, such as file ID and user ID. This will allow you to track each file and its associated information. If you want to add a tag to a file and filter files based on that tag, you can create a separate collection to store the details and update it after each upload. Using different buckets is not necessary for this purpose.
Binyamin
4 Sep, 2023, 18:53

To keep tracking of your file the best workaround is to create collection that will have all the details, for example

  • file_id
  • user_id
  • ... Then update it after each upload
bladmist
4 Sep, 2023, 19:09

I referring to files like a pdf. I thought they can only go in storage?

Binyamin
4 Sep, 2023, 19:10

You always put the file inside a bucket using the storage module But if you want to track each file meta_data you will need to create an accompanied collection

bladmist
4 Sep, 2023, 19:14

ah, I see, so as I upload a file, I simultaneously update the collection?

Binyamin
4 Sep, 2023, 19:14

Yes

Binyamin
4 Sep, 2023, 19:15

And you can use events for that Creating a function that will get triggered on each file upload Then you can easily update the collection

bladmist
4 Sep, 2023, 19:16

Okay, I'd do so. Thanks for your advice

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