flutter_uploader icon indicating copy to clipboard operation
flutter_uploader copied to clipboard

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

Open bachras opened this issue 4 years ago • 11 comments

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

bachras avatar May 17 '21 06:05 bachras

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

ened avatar May 17 '21 10:05 ened

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)

bachras avatar May 17 '21 14:05 bachras

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.

ened avatar May 17 '21 16:05 ened

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

bachras avatar May 19 '21 06:05 bachras

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

akhelij avatar Jun 13 '21 21:06 akhelij

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), {})

orestesgaolin avatar Feb 07 '22 16:02 orestesgaolin

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

ened avatar Feb 07 '22 18:02 ened

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

orestesgaolin avatar Feb 08 '22 09:02 orestesgaolin

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.

ened avatar Feb 08 '22 10:02 ened

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"
        }
    }
}

orestesgaolin avatar Feb 08 '22 16:02 orestesgaolin

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.

ened avatar Feb 08 '22 16:02 ened