Back

[SOLVED] Appwrite function to reduce file Size

  • 0
  • Functions
  • Storage
Monzim
5 Apr, 2023, 16:49

After the user uploads a file to the bucket I want to reduce its size using a function with the help of the sharp node js library. I was wondering if when I am saving the file sharp().toFile() method and then re-upload it to the bucket is the file going to live in the open runtime container? If the worker clears the container is the file going to live on the disk?

TL;DR
The user wants to implement image compression for Appwrite. It is recommended to check out the Storage and Process Photo sections in the provided link. When using the sharp library, the file will live in the open runtime container. If the worker clears the container, the file will be removed. To update the file, create a new file in Appwrite Storage and remove the old one by its ID. Use the new ID wherever needed.
joeyouss
5 Apr, 2023, 16:59

Hi

joeyouss
5 Apr, 2023, 17:00

It is gonna be in separate runtimes

joeyouss
5 Apr, 2023, 17:00

And regarding re-uploading, it's important to mention you cannot updateFile. You would need to create new file in Appwrite Storage, and remove old one by it's ID. Then use new ID where-ever you need

Monzim
5 Apr, 2023, 17:15

so after the function is completed the disk file will be removed by the runtime?

joeyouss
5 Apr, 2023, 17:26

worst-case scenario, it will be removed after 15 minutes of inactivity (when runtime stops). Its still recommended to delete the file anyway, yes. To preserve disk space.

Monzim
5 Apr, 2023, 17:55

Thanks. Is there any better way to implement image compression for appwrite?

Drake
6 Apr, 2023, 00:54
Tessa
7 Apr, 2023, 21:11

@Monzim everything good on your end so we can close this? 🙂

Monzim
9 Apr, 2023, 14:30

[SOLVED] Appwrite function to reduce file Size

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