Data cannot occupy more than 10240 bytes when serialized
dev-lcc opened this issue · 5 comments
Bug report for Cloudinary Android SDK
Before proceeding, please update to latest version and test if the issue persists
- Using the latest
master-SNAPSHOT
build, which includes PR Replace EverNote with Android WorkManager
Describe the bug in a sentence or two.
- Cloudinary Upload operation throws exception "Data cannot occupy more than 10240 bytes when serialized".
- It seems like when creating UploadRequest payload(since it is now using androidx.workmanager), instantiation of Data payload now exceeds the maximum number of bytes(https://developer.android.com/reference/androidx/work/Data#MAX_DATA_BYTES()).
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
"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: 5f61b6c'
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
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
PR Filed:
#147
- I have removed the WakeLock code logic from Worker as it causes Runtime Exception("WakeLock under-locked")
- I think the WakeLock logic was only necessary for Evernote Job implementation.
@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).