You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
aertms
changed the title
Save link in database?
Question: Save link in database?
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 theuserName
I could also save theuserPictureUrl
. 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?
The text was updated successfully, but these errors were encountered: