Back

Increase function response size to 3-5MB

  • 0
  • Functions
50l3r
18 Aug, 2023, 14:50

Since the storage system of each client is different, the saving is done in the backend instead of in the appwrite function

TL;DR
User is asking for help on increasing the function response size to 3-5MB. They have implemented it in several projects and need to test it in development before uploading it to production. The current limit is 1MB in the database, so the user suggests using storage as a better alternative. They ask if there is a way to programmatically delete files after a certain time. The suggested change is to capture the URL of the file instead of a buffer in the function return. The user also mentions temporarily solving the problem by reducing the size of the PDF before returning it. The user expresses appreciation for the help and asks if it will
Drake
18 Aug, 2023, 14:51

What's client platforms do you have? What backend are you referring to?

50l3r
18 Aug, 2023, 14:52

These are management applications made in vue3 in the frontend part and Typescript in the backend part.

50l3r
18 Aug, 2023, 14:53

Clients have a billing application and the appwrite function is responsible for collecting the invoice data and creating the pdf document

Drake
18 Aug, 2023, 14:53

So you're using nuxt with a server side backend?

What's calling the function? The browser or the server side back end?

50l3r
18 Aug, 2023, 14:55

Yes, i dont use nuxt only vue but its the same.

50l3r
18 Aug, 2023, 14:55

I call the function in the server side

Drake
18 Aug, 2023, 15:44

so if your function puts it in storage, your server can use storage.getFileView() to get the file buffer

50l3r
18 Aug, 2023, 16:25

Yes, I understand the procedure. Store the file and facilitate access to download it via appwrite storage.

The question to increase the response size was to have a temporary solution since the file system will take some time to implement it in several clients.

50l3r
18 Aug, 2023, 16:26

Thanks for your time and help @Steven I apreciate your job and dedication to this awesome plattform 🙂

Drake
18 Aug, 2023, 16:37

what file system???? There is no file system involved in what i am suggesting

50l3r
18 Aug, 2023, 16:39

I'm sorry, maybe I didn't explain well

What I mean is that it will take me some time to change the implementation on the server side since there are several clients.

Instead of capturing a buffer in the return of the function, now it should capture something lighter like the url of the file to be able to download it previously on the server side.

Drake
18 Aug, 2023, 16:41

it will take time to make any sort of change to the server side code?

50l3r
18 Aug, 2023, 16:41

Yes

50l3r
18 Aug, 2023, 16:42

For the moment I have managed to solve the problem temporarily, reducing the size of the pdf before returning it.

Drake
18 Aug, 2023, 16:44

because the change should be something like:

TypeScript
const execution = functions.createExecution('[FUNCTION_ID]');
const buffer = execution.response;

to:

TypeScript
const execution functions.createExecution('[FUNCTION_ID]');
const fileId = execution.response;
const buffer = storage.getFileView('[BUCKET_ID]', fileId);
50l3r
18 Aug, 2023, 16:44

Would there be a simple way to programmatically delete the files after x time?

Drake
18 Aug, 2023, 16:45

create an Appwrite Function that runs on a schedule to find and delete files

50l3r
18 Aug, 2023, 16:45

great

Drake
18 Aug, 2023, 16:46

anyways...changing the limit can be complex because it's limited to 1MB in the database: https://github.com/appwrite/appwrite/blob/96fa7362f3f045c242758b7e42469e982a3039bf/app/config/collections.php#L2691-L2701

and the data from the runtime is trimmed: https://github.com/appwrite/appwrite/blob/96fa7362f3f045c242758b7e42469e982a3039bf/app/executor.php#L578-L580

that's why using storage is a much better alternative

50l3r
18 Aug, 2023, 16:48

Yes, I noticed that when trying to parse the response JSON it indicated that it was not valid. I saw that feature on github where you guys talked about: https://github.com/appwrite/appwrite/issues/3434

50l3r
18 Aug, 2023, 16:49

The change is simple but since I have it implemented in several projects I will need to take some time to test it in development and then upload it to production.

50l3r
18 Aug, 2023, 16:50

But we agree that the file system is the best option.

Drake
18 Aug, 2023, 16:50

makes sense. thanks for the insight 👍🏼

50l3r
18 Aug, 2023, 16:50

Thanks 4 all @Steven

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