We are currently working with Directus and facing a limitation regarding file sharing.
Use Case:
We have created custom user roles and want to generate shareable links for files stored in the default directus_files collection. The goal is to share these files with existing users so they can access and edit them.
Issue:
-
Directus allows creating shareable links via custom collections.
-
However, we are unable to generate or manage shareable links directly for items in the default directus_files collection.
-
We also want to manage these shareable links through a custom collection (e.g., store link, permissions, expiry, etc.).
Expected Behavior:
-
Ability to generate shareable links directly for files in directus_files, OR
-
A recommended approach to associate files with a custom collection and generate/manage shareable links from there.
Any guidance or best practices would be really helpful.
Thanks in advance!
2 Answers
2
My rec here would be to setup a “Public” folder in the file library, and then configure the permissions for reading files to allow the public role to read all files in the public folder, that way you can share those links directly with people while maintaining a boundary of what files are sharable and what files aren’t
@rijkvanzanten
Sorry for the confusion earlier. What I actually want to achieve is generating editable shareable links for media files stored in the default directus_files collection, similar to how Directus creates share links for custom collections.
Reference screenshots
I tried implementing this using a custom extension, but I am getting the following error:
{
"errors": [
{
"message": "Invalid foreign key \"directus_files\" for field \"collection\" in collection \"directus_shares\".",
"extensions": {
"collection": "directus_shares",
"field": "collection",
"value": "directus_files",
"code": "INVALID_FOREIGN_KEY"
}
}
]
}
I am using the same payload structure that Directus uses for generating shareable links for custom collections.
Could you please guide me on this?
-
Is it possible to create shareable/editable links directly for items in directus_files?
-
If not, what would be the recommended approach to achieve this functionality?
Any guidance or best practices would be really helpful.