Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Save link in database? #873

Open
aertms opened this issue Jun 6, 2023 · 0 comments
Open

Question: Save link in database? #873

aertms opened this issue Jun 6, 2023 · 0 comments

Comments

@aertms
Copy link

aertms commented Jun 6, 2023

I have a question about this package and what would be the best way to use it in our case. We use it to upload files to S3. This question is specifically about users' profile pictures. I looked through the documentation but didn't find anything specific about this question, sorry if I missed something.

What we've been doing so far: When the users change their profile pictures the new picture is uploaded and the filename is set to <userId>.jpg. The old profile picture is deleted. When I need to show the profile picture I have a component that includes a subscription to that file object with the filename as parameter, which I get from the user id. And then I set the image tag with <img src={file.link()} />.

When the profile pictures are shown in a lot of different places it creates a lot of subscriptions and I'm wondering if that's the best way to do it or if there is a better way.

An alternative I thought of is this: When uploading the profile picture I immediately get the link() of the file and save that in the user object. So in other places in the app where I currently save the userId and the userName I could also save the userPictureUrl. That way I have access to the url directly and don't need to subscribe to the file object.

Would that be better than subscribing to all the files individually, also from a performance point of view? Or are there other best practices for a use case like this?

@aertms aertms changed the title Save link in database? Question: Save link in database? Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant