Back

Updating a User Storage File

  • 0
  • Storage
SenZi
21 Feb, 2023, 00:03

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!

TL;DR
The user wants to allow users to upload and update their profile pictures without incurring high bandwidth costs or allowing for multiple files to be created. They are currently considering deleting all existing files when a user uploads a new one, but are unsure about how to handle updates. They are also concerned about users being able to create multiple files directly in the storage bucket. They are looking for suggestions on how to approach this and wondering if there are any plans to support file updates in the API. One possible solution is to let users upload to an upload bucket, then use a function to process the upload, delete old files if necessary, and upload the new
Drake
21 Feb, 2023, 00:21

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

SenZi
21 Feb, 2023, 00:25

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?

Drake
21 Feb, 2023, 00:28

Yes, just permission

SenZi
21 Feb, 2023, 00:31

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.

Drake
21 Feb, 2023, 00:48

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

Drake
21 Feb, 2023, 00:54

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?

SenZi
21 Feb, 2023, 00:57

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.

Drake
21 Feb, 2023, 00:59

So what's your big primary goal again?

SenZi
21 Feb, 2023, 01:00

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.

Drake
21 Feb, 2023, 01:04

If you keep it simple, and just let them upload a new file, you'd have the same result, right?

SenZi
21 Feb, 2023, 01:06

but when updating i would have to delete the old file and it still lets users upload as many files as they want directly.

SenZi
21 Feb, 2023, 01:07

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

Drake
21 Feb, 2023, 01:25

So the goal is to

  1. let the user upload and update their profile picture
  2. Don't go too crazy with bandwidth
  3. Don't let the user have orphaned profile pictures
SenZi
21 Feb, 2023, 01:25

yeah exactly

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more