zetbaitsu / Compressor

An android image compression library.
7.04k stars 961 forks source link

Android 11 - open failed: EACCES (Permission denied) #182

Open ubarua123 opened 3 years ago

ubarua123 commented 3 years ago
  1. I have already added requestLegacyExternalStorage which does not work SDK > 29
  2. User gives permission to write to storage but the problem here is the library is trying to write somewhere else for compression which is not allowed android 11 onwards.

Exception -

kotlin.io.FilesKt__UtilsKt.copyTo (FilesKt__UtilsKt.java:235)
kotlin.io.FilesKt__UtilsKt.copyTo$default (FilesKt__UtilsKt.java:217)
id.zelory.compressor.UtilKt.copyToCache (UtilKt.java:82)
id.zelory.compressor.Compressor$compress$3.invokeSuspend (Compressor.java:25)
id.zelory.compressor.Compressor$compress$3.invoke (Compressor.java:2)
kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn (UndispatchedKt.java:91)
kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext (BuildersKt__Builders_commonKt.java:165)
kotlinx.coroutines.BuildersKt.withContext (BuildersKt.java:1)
id.zelory.compressor.Compressor.compress (Compressor.java:23)
id.zelory.compressor.Compressor.compress$default (Compressor.java:22)

I am using Library version 3.0.0

aakash-gavle commented 3 years ago

How to compress images for Android 10 and above? Can you give me name of some other good library

nexy791 commented 3 years ago

You cannot use this permission on devices 11+

You can open file to compress by path that provided by URI and then write this file by uri You should get URI by intent like ACTION_GET_CONTENT

rohitjakhar commented 1 year ago

can you provide sample code?