You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
try {
var result = await http.post(
_uploadDescription.url,
body: await _readStreamData(stream),
headers: {
'Content-Type': 'application/octet-stream',
'Accept': '*/*',
},
);
return result.statusCode == 200;
} catch (e) {
return false; // I end up here with an `Invalid array length` error
}
To reproduce
This is what i
var uploader = FileUploader(uploadDescription);
final result = await uploader.uploadByteData(ByteData.view(fileBytes.buffer));
Or this
var uploader = FileUploader(uploadDescription);
final fileStream = Stream.value(fileBytes.toList());
final length = fileBytes.length;
final result = await uploader.upload(fileStream, length);
Both of them result false.
Expected behavior
I expect the upload to succeed
Library version
2.8.0
Platform information
Web
Additional context
No response
How experienced are you with this library?
Expert - Experienced and comfortable with using this library in complex projects
@vanlooverenkoen How big is the apk you are trying to upload? What is the uploadDescription passed? (or just the url). I see we don't trace anything about the error, but did you try to set a breakpoint in the catch clause to see the actual exception? I would like to know the exact type, and any related data it might carry.
Could you check your pubspec.lock? This should give about a factor of 8 in memory, due to the internal Uint8List buffer, which should bring 71MB below the memory use of the 13MB apk you successfully uploaded before.
Activity
[-]Upload apk results in: Invalid array length[/-][+]File upload results in: Invalid array length[/+]SandPod commentedon Jun 12, 2025
Thanks for the report!
We will try to get to this as soon as possible 👍
vanlooverenkoen commentedon Jun 17, 2025
@SandPod any idea why this is failing? I think my setup is correct (because it works for ipa files, they are smaller so maybe that is the issue?)
I also have set
maxRequestSize: 200000000SandPod commentedon Jun 19, 2025
Sorry, I have not been able to dig into this one yet.
I have added it to our list over prioritized bugs. I hope that we can give you a response on this soon.
nielsenko commentedon Jun 19, 2025
@vanlooverenkoen How big is the apk you are trying to upload? What is the
uploadDescriptionpassed? (or just the url). I see we don't trace anything about the error, but did you try to set a breakpoint in the catch clause to see the actual exception? I would like to know the exact type, and any related data it might carry.nielsenko commentedon Jun 19, 2025
What runtime are you using?
vanlooverenkoen commentedon Jun 19, 2025
The uploadDescription is done exactly how it was documented:
https://docs.serverpod.dev/concepts/file-uploads#client-side-code
The apk is 71mb
The error that I found was
Invalid array length, I'm not sure where I can get extra info on this errorvanlooverenkoen commentedon Jun 19, 2025
What do you mean with runtime?
develop
monolith
vanlooverenkoen commentedon Jun 19, 2025
Let me try and get the runtimeType of that specific error.
vanlooverenkoen commentedon Jun 19, 2025
I am also running on web. Maybe that is related? Using https://pub.dev/packages/file_picker
vanlooverenkoen commentedon Jun 19, 2025
JSRangeErroris the actual error.7 remaining items
nielsenko commentedon Jun 19, 2025
Could you check your
pubspec.lock? This should give about a factor of 8 in memory, due to the internalUint8Listbuffer, which should bring71MBbelow the memory use of the13MBapk you successfully uploaded before.vanlooverenkoen commentedon Jun 19, 2025
This is inside my lock file:
I also debugged and saw the new code was being used as well
nielsenko commentedon Jun 20, 2025
@vanlooverenkoen This is not what I would expect. It should look like:
Did you take a direct dependency on "my" serverpod_client? Did you run
dart pub upgrade?vanlooverenkoen commentedon Jun 20, 2025
Oh sorry the snippet was from the server pubspec.lock
This is the frontend

This is my pubspec
vanlooverenkoen commentedon Jun 20, 2025
I removed the pubspec.lock and I just get the same result.
When running the app I still get the
vanlooverenkoen commentedon Jun 20, 2025
@nielsenko wouldn't it make more sense to use a
StreamedRequestinstead? And upload the requests in chunks?vanlooverenkoen commentedon Jun 20, 2025
I just fixed the issue here locally. Let me create a new Pull Request
vanlooverenkoen commentedon Jun 20, 2025
@nielsenko #3697
vanlooverenkoen commentedon Jun 20, 2025
I did not see you already created this one: #3695
The
StreamedRequestdoes work indeed (at least the PR I created is what worked perfectly)nielsenko commentedon Jun 20, 2025
You can try my PR with:
It should land soon.
nielsenko commentedon Jun 20, 2025
@vanlooverenkoen I wasn't aware you intended to work on this.
vanlooverenkoen commentedon Jun 20, 2025
No worries, I was just playing around in debugging and accidentally found the fix :D
vanlooverenkoen commentedon Jun 20, 2025
Yes this works! Also the UI thread is not frozen anymore! Good job @nielsenko