Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Foks's avatar
Level 15

File sharing?

I'm currently working on a file manager, think of it as google drive in my own application, however, I need to allow the file owner to share files between users, but I'm not sure how to approach this. I hope that some of you would be able to provide some viable insight into this matter. I plan to use this with an S3 bucket and then store the file information and path in the database.

Thanks in advance.

0 likes
4 replies
jlrdw's avatar

Something like a related table of users id authorized to view a certain image.

someimage014za12.jpg
     ----56
     ----197
     ----1005
     ----2897
     etc

Can view the image. A little more involved but hopefully you get the idea. Foreign keys will be needed, etc.

1 like
MohamedTammam's avatar

That's how I would do it.

First you should create a route for files, something like example.com/files/{file_id}. Then you create a many-to-many relationship with between file and users who can access it. And maybe you store a uuid to the file and if someone has it will also be able to access it via a route like example.com/files/{file_id}/{uuid]

1 like
Shaun_Fit22's avatar

Use your database to manage file permissions (owner, shared users, access level) and check these before generating pre-signed S3 URLs. This way, only authorized users can access or download the shared files. You made a tremendous product by merging the idea of storing files like cloud and sharing large data with each other like https://xendarapp.com .

Please or to participate in this conversation.