Hi, I was looking at the docs and the discord community and found that the storage api does not allow for a file update. So i was wondering how would i go about updating, lets say, a profile image. As per previous solutions, i can create a file, delete the old one and update the id. But doesn't this allow the frontend user to create as many files as they want?
What i was doing right now was using functions when a user creates a new account to generate a profile image and granting update and read permission to the particular user so that they can update and read that file later but due to update file api limitation i dont think that idea would work anymore.
Do i have to create another function to handle user profile image uploads because i dont want to allow users to create any file they want directly to the storage bucket.
Any help pointing in the right direction would be nice. Thanks!
Using the storage API is best for files so that you can also upload in chunks.
I would just let users upload to an upload bucket. Then, a function can process the upload, maybe delete if they shouldn't have rights or something, and then upload to another bucket where it will be served
But uploading to the storage bucket without any control seems like they might abuse the api, also storage buckets sync to the external s3 storage provider who charges based on bandwith too... It would be great to have a way to update the file.
May i also ask what the update permission for the file is? Just the permissions?
Yes, just permission
Is there any plans to update the api to support File Updates, because in the current use case it seems more secure and very useful.
It might be good for you to create a Feature request. Not for updating a file but your use case on letting a user only upload one file and that using a separate upload bucket could still incur high bandwidth costs
So even if you allowed updating a file. How will you prevent someone from changing their profile id over and over again incurring high bandwidth costs?
bandwidth cost might still be a issue, but there wont be unnecessary spam data from allowing a user to upload file in the first place. As you mention earlier i could create a upload bucket and then use maybe functions to process that. That includes extra steps and processing power.
So what's your big primary goal again?
User Profile Image, Which they can update. I create a default profile picture so that they can only update it, but i thought the update file function would update the file, just read the docs in detail now.
If you keep it simple, and just let them upload a new file, you'd have the same result, right?
but when updating i would have to delete the old file and it still lets users upload as many files as they want directly.
I think right now i might have to go with deleting all the existing files of a user when they upload one, which would prevent multiple files from a user existing
So the goal is to
- let the user upload and update their profile picture
- Don't go too crazy with bandwidth
- Don't let the user have orphaned profile pictures
yeah exactly
Recommended threads
- Storage files aren’t showing on mobile
hi, what can be the problem? i have a storage and there are images in it, the permissions are read for All Users, everything is fine on desktop, but on mobile t...
- Delete storage files all at once
I am using Appwrite Cloud. I want to delete all storage files in my bucket similar to how I can select all documents in a collection and delete them all at once...
- Storage images are not showing on mobile
Hi, can anyone help me? I have some images on the storage, and it is not shown on mobile, on desktop everything is fine.