fluttercommunity / flutter_uploader

background upload plugin for flutter
MIT License
211 stars 140 forks source link

Ability to receive responseBytes and avoid 'Data cannot occupy more than 10240 bytes' error #167

Open bachras opened 3 years ago

bachras commented 3 years ago

I have fully implemented your package into my app and now I have an error 'Data cannot occupy more than 10240 bytes when serialized' also mentioned in https://github.com/fluttercommunity/flutter_uploader/issues/58 when I receive larger json response.

Do you know any workaround for large than 10kb responses? I was trying to compress response on backend and decompress flutter but I need response in bytes and file uploader gives me string as response. Any ideas how to get response in bytes. Thank you in advance

ened commented 3 years ago

@bachras I assume this is on Android, right? Can you just post a stack trace for reference? I will look at this asap.

bachras commented 3 years ago

Yes, it's Android. Currently using flutter_uploader: ^1.2.1 (haven't updated app to null-safety yet, but had same issue on flutter_uploader latest version (3.0.0-beta.1) on different app as well)

W/System.err(11226): java.lang.IllegalStateException: Data cannot occupy more than 10240 bytes when serialized
W/System.err(11226):    at androidx.work.Data.toByteArrayInternal(Data.java:417)
W/System.err(11226):    at androidx.work.Data$Builder.build(Data.java:846)
W/System.err(11226):    at com.bluechilli.flutteruploader.UploadWorker.doWork(UploadWorker.java:278)
W/System.err(11226):    at androidx.work.Worker$1.run(Worker.java:85)
W/System.err(11226):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err(11226):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err(11226):    at java.lang.Thread.run(Thread.java:764)
ened commented 3 years ago

If you are using 1.2.1, help may be unavailable. The plugin's 3.0.0-beta.1 version is likely to go stable in the coming weeks, no support for 1.2.1 can be provided currently.

bachras commented 3 years ago

I appreciate that 1.2.1 version support is no longer available and that's fine. I am planning to update it anyway, I just wanted to point out for reference purposes. As I mentioned earlier same issue occurs on 3.0.0-beta.1 version as well. Thanks

akhelij commented 3 years ago

Facing the same problem on 3.0.0-beta.1. Any solution yet !

orestesgaolin commented 2 years ago

Getting the same error on flutter_uploader: ^3.0.0-beta.3 when trying to upload ~700KB file

I[/flutter]() ( 6811): Result: UploadTaskResponse(9f97804d-1c3e-4e26-b026-648283f81780, java.lang.IllegalStateException: Data cannot occupy more than 10240 bytes when serialized, 500, UploadTaskStatus(4), {})
ened commented 2 years ago

Could you build a repro case in this repos integration test suite, then it will be easier to prepare a fix.

orestesgaolin commented 2 years ago

I will try to reproduce on the example app and contribute the test, thanks

ened commented 2 years ago

I will try to reproduce on the example app and contribute the test, thanks

You may want to use the current main branch for writing the test. Thank you for your help.

orestesgaolin commented 2 years ago

Do you know if there's a workaround to this issue https://github.com/flutter/flutter/issues/98012? I'm trying to make a test that returns a big json response, something like below, but cannot run integration tests on Android emulator.

{
    "data": {
        "type": "video",
        "id": "177",
        "attributes": {
            "account_id": 1,
            "title": "image_picker7442792663695358144.mp4",
            "video_url": "https://somes3url.com/XL71.mp4",
            "thumb_url": "https://somes3url.com/thumbnail.jpg",
            "other_id": "",
            "status_id": 0,
            "date_uploaded": "2022-02-08T16:16:53.803000Z"
        }
    }
}
ened commented 2 years ago

The only workaround I know is to reduce the method count by removing dependencies. gson is a good candidate to get rid of and replace with androids built in methods.

We're not over 64k by much.