Page 1 of 1

JS API: file size limits for file access?

Posted: 08 Aug 2019 09:47
by piet66
Are there file size limits for file access using JS API, like
http:.../JS/Run/loadObject("filename")
and
http:.../JS/Run/saveObject("filename")
?

What are the limits and what do we get back when limit is exceeded?

Re: JS API: file size limits for file access?

Posted: 09 Aug 2019 02:50
by PoltoS
Limit is the memory limit of your Pi. You get an exception if it is exceeded. Otherwise there are no limits.

But JSON is a bad format for big files

Re: JS API: file size limits for file access?

Posted: 11 Aug 2019 10:22
by piet66
I tested loadObject with the standard ZWay files. 4 of them return null:
http://IP:8083/JS/Run/loadObject('dedevices.json')
http://IP:8083/JS/Run/loadObject('endevices.json')
http://IP:8083/JS/Run/loadObject('zwayo ... ckets.json')
http://IP:8083/JS/Run/loadObject('zwayp ... ckets.json')

These 4 are the largest files of all:
-rwxr-xr-x 1 4142694 Apr 19 13:49 dedevicesjson-b02fc6609e0022e8f55ff6bb5b853d35.json
-rwxr-xr-x 1 4103417 Apr 19 13:49 endevicesjson-7904daacdb872d656b01c6c9eddd3a48.json
-rwxr-xr-x 1 621220 Aug 11 08:31 zwayoriginPacketsjson-2ad2998bc2cb543d29ac586cec215398.json
-rwxr-xr-x 1 817011 Aug 11 08:31 zwayparsedPacketsjson-f1aed46af7fae1368e78db7768e4d9e5.json

For saveObject there seems to be a buffer size limit of about 6000 bytes. Larger buffers cause an error {"readyState":0,"status":0,"statusText":"error"}.

Re: JS API: file size limits for file access?

Posted: 11 Aug 2019 11:13
by PoltoS
This should be HTTP limit and not API

Re: JS API: file size limits for file access?

Posted: 11 Aug 2019 11:47
by piet66
Is it a limit of ZWay webserver? Where is it configured?

Re: JS API: file size limits for file access?

Posted: 12 Aug 2019 10:53
by piet66
piet66 wrote:
11 Aug 2019 10:22
I tested loadObject with the standard ZWay files. 4 of them return null
It's not the filesize but the filename. After storing those file with a different valid filename it works.
piet66 wrote:
11 Aug 2019 11:47
Is it a limit of ZWay webserver? Where is it configured?
It's obviously the ZWay embedded webserver. I tested it with netcat.
Apache server also has such a limit: LimitRequestLine 8190

Re: JS API: file size limits for file access?

Posted: 14 Aug 2019 04:32
by PoltoS
We should use mongoose default values

Re: JS API: file size limits for file access?

Posted: 15 Aug 2019 10:13
by piet66
PoltoS wrote:
14 Aug 2019 04:32
We should use mongoose default values
Of course, but I found it nowhere documented.
Now looked into mongoose code: #define MG_MAX_HTTP_REQUEST_SIZE 8192