cloudinary / cloudinary_android

Android client for integrating with Cloudinary
MIT License
67 stars 59 forks source link

Data cannot occupy more than 10240 bytes when serialized #146

Closed dev-lcc closed 2 years ago

dev-lcc commented 2 years ago

Bug report for Cloudinary Android SDK

Before proceeding, please update to latest version and test if the issue persists

Describe the bug in a sentence or two.

Issue Type (Can be multiple)

[ ] Build - Can’t install or import the SDK [ ] Performance - Performance issues [x] Behaviour - Functions aren’t working as expected (Such as generate URL) [ ] Documentation - Inconsistency between the docs and behaviour [ ] Other (Specify)

Steps to reproduce

Given the sample upload code snippet:

val data: ByteArray = // ... The Image in a form of ByteArray about to upload.
mediaManager
    .upload(data)
    .unsigned("<cloudinaryUploadPreset>")
    .constrain(TimeWindow.immediate())
    // ... Other chain builder options
    .policy(
        UploadPolicy.Builder()
            .maxRetries(3)
            .networkPolicy(UploadPolicy.NetworkType.ANY)
            .build()
    )
    .dispatch()

Error screenshots or Stack Trace

image

    "androidx.work.Data.toByteArrayInternal(Data.java:417)"
    "androidx.work.Data$Builder.build(Data.java:846)"
    "com.cloudinary.android.UploadRequest.buildPayload(UploadRequest.java:343)"
    "com.cloudinary.android.AndroidJobStrategy.adapt(AndroidJobStrategy.java:48)"
    "com.cloudinary.android.AndroidJobStrategy.doDispatch(AndroidJobStrategy.java:89)"
    "com.cloudinary.android.DefaultRequestDispatcher.dispatch(DefaultRequestDispatcher.java:54)"
    "com.cloudinary.android.UploadRequest.doDispatch(UploadRequest.java:246)"
    "com.cloudinary.android.UploadRequest.dispatch(UploadRequest.java:203)"
    "com.cloudinary.android.UploadRequest.dispatch(UploadRequest.java:171)"
    ...
    ...

Build System

[ ] Maven [x] Gradle [ ] Other (Specify)

Is the issue reproducible only on a specific device?

[x] No [ ] Yes (specify model + Android version + vendor build number, if applicable)

Versions and Libraries (fill in the version numbers)

Cloudinary Android SDK version 'master-SNAPSHOT' / 'commit: 5f61b6cccace0fc7ec611b104a46a6528d0cb87e' Android version - 12 Kotlin version (if applicable) - 1.7.10 JVM (of the dev environment) - 11.0.16.1 Maven - 0.0.0 / N/A Gradle - 7.2.0

adimiz1 commented 2 years ago

Hi dev-lcc Thank you very much for reporting this issue Until an official fix will be introduced I suggest sending the path to the file and not the byte array itself You can wrap it with FilePayload class For example: new FilePayload(data.getPath()) Where data is a File object

dev-lcc commented 2 years ago

PR Filed: https://github.com/cloudinary/cloudinary_android/pull/147

dev-lcc commented 2 years ago

@adimiz1 I have used a separate approach for creating a placeholder file as I believed that the FilePayload class was intended to store Image/Video data(as Base64 encoded string).

adimiz1 commented 2 years ago

@dev-lcc thank you very much for submitting your PR, we'll go through it and will contact you if needed

adimiz1 commented 2 years ago

@dev-lcc thank you very much for your submission, your PR was merged with the fix, therefore I'm closing down the issue. If the problem persists please feel free to open another issue