Back

Transmit large array to function

  • 0
  • Self Hosted
Binyamin
22 Jun, 2023, 19:02

Mmm, this one is 20K long Meaning is more then the 8192 chars limit.

TL;DR
The user is encountering limitations when trying to transmit a large array to a function in the Appwrite platform. They mention specific lines of code that set a 1MB limit on the response payload. They also provide suggestions for changing the limit and mention the option to split the array into smaller chunks. They inquire about the reasoning behind these limitations and discuss using the Appwrite Storage module as an alternative solution. No specific error is mentioned.
elemin67
22 Jun, 2023, 19:02

yes chatgpt says 10K πŸ™‚

Binyamin
22 Jun, 2023, 19:03
Binyamin
22 Jun, 2023, 19:03

With this amount of data you'll need to choose a different approach

Binyamin
22 Jun, 2023, 19:04

You'll need to use the Appwrite Storage module.

  1. Upload the file to storage using createFile https://appwrite.io/docs/server/storage?sdk=web-default#storageCreateFile
  2. In the function fetch the file using getFile https://appwrite.io/docs/server/storage?sdk=web-default#storageGetFile
  3. Then, just delete it https://appwrite.io/docs/server/storage?sdk=web-default#storageDeleteFile
Binyamin
22 Jun, 2023, 19:05

Or

elemin67
22 Jun, 2023, 19:06

Okay, I feared that πŸ™‚ I tried to find a solution without storage.

Binyamin
22 Jun, 2023, 19:07

You can dived the Base64 string into 8000 chars chunks, then in the function you can try do maybesomthing like this

TypeScript
for(let chunk in chunks){
   await this.appwrite.functions.createExecution(functionId, JSON.stringify({lastChunk: false, chunk: chunk }), async);
}
Binyamin
22 Jun, 2023, 19:07

It's possible but will require some extra work from your side.

Binyamin
22 Jun, 2023, 19:07

And its actually good option if you want to avoid storage.

elemin67
22 Jun, 2023, 19:09

but thanks for your help. I will try to split the array into chunks less hen 8000 chars. If i find something. I can share it with you

Binyamin
22 Jun, 2023, 19:09

πŸ‘

elemin67
22 Jun, 2023, 19:09

But why is there a limitation from appwrrite. Do you know it?

Binyamin
22 Jun, 2023, 19:10

Probably against abuse

elemin67
22 Jun, 2023, 19:11

hmm, okay. but for self host there should be a option to change the limitations. but its okay. We can find something

Binyamin
22 Jun, 2023, 19:12

You are on self host?

elemin67
22 Jun, 2023, 19:13

yes

elemin67
22 Jun, 2023, 19:13

im not using the cloud

Binyamin
22 Jun, 2023, 19:19

Change it to let's say 100000 You can still use the zip choice to get shorter upload times.

elemin67
22 Jun, 2023, 19:20

nice, I will try that definitly. Big thanks. That would help. I will keep you up-to-date

elemin67
22 Jun, 2023, 21:22

the response payload is also limited. It trims in the and that affacting the large object. That means the response payload cuts after some limit. You know in the code where to change it?

Binyamin
23 Jun, 2023, 01:10

What error do you get?

Binyamin
23 Jun, 2023, 01:17

Any time you see this line

TypeScript
  \mb_strcut($res, 0, 1000000), // Limit to 1MB

Like in here https://github.com/appwrite/appwrite/blob/master/app/executor.php#L578 It's when the limit of the response is set 1MB, just change it to whatever number you like.

Binyamin
23 Jun, 2023, 01:19

But, do notice this line, that saves the response into the database https://github.com/appwrite/appwrite/blob/master/app/controllers/api/functions.php#L1175 As it have only 1MB limit https://github.com/appwrite/appwrite/blob/master/app/config/collections.php#L2695

So you'll also to find a way around it, either by change the length, or simply just just command out the insertion line.

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