Giter Club home page Giter Club logo

Comments (8)

TomasMVazquez avatar TomasMVazquez commented on May 28, 2024 2

Hi,
In my case I solved the problem following this:
https://developer.android.com/training/data-storage/shared/documents-files?hl=es-419

Hope it helps you too!
Regards,

from android-image-cropper.

Canato avatar Canato commented on May 28, 2024

Hey @RanjitPati I'm on holidays for the next weeks, but this don't look like a library issue.
The URI is returning correctly, since you can put it on the ImageView, like you said.

I cannot see the code to create the file, but maybe you can't create the file using the same URI because of the Android Scope Storage, something to check.

The bug here would be wrong URI value return, but this is working.
So not sure what the bug could be.

Open to discussions so we can solve this and help you =D

from android-image-cropper.

RanjitPati avatar RanjitPati commented on May 28, 2024

I am creating the file like new File(uri.getPath()) . The same code was working before. @TomasMVazquez Can you please share the piece of code which you have used to create the file from the uri.

from android-image-cropper.

Canato avatar Canato commented on May 28, 2024

I am creating the file like new File(uri.getPath()) . The same code was working before. @TomasMVazquez Can you please share the piece of code which you have used to create the file from the uri.

@RanjitPati maybe this is happening because of Android OS permission changes.

Now using scope storage we don't get a file path anymore.

Maybe you can change the URI string "content" to "file"

But is not the real fix, the library will return the URI for the image using the scope storage like google force us now.

If you plan to create a file you need to get write storage permission and get the path where you put the image.

Make sense?

from android-image-cropper.

AbdulmalekAlshugaa avatar AbdulmalekAlshugaa commented on May 28, 2024

com.theartofdev.edmodo:android-image-cropper:2.8.0
It works here pretty fine, you can check this library for you reference.

from android-image-cropper.

TomasMVazquez avatar TomasMVazquez commented on May 28, 2024

I am creating the file like new File(uri.getPath()) . The same code was working before. @TomasMVazquez Can you please share the piece of code which you have used to create the file from the uri.

What I needed was to get Base64 from Uri/Path, originaly I was getting the path but with the change I'm using directly the Uri:

Original Code:

fun imageFileToBase64(imageFile: File): String {
    return FileInputStream(imageFile).use { inputStream ->
        ByteArrayOutputStream().use { outputStream ->
            Base64OutputStream(outputStream, Base64.DEFAULT).use { base64FilterStream ->
                inputStream.copyTo(base64FilterStream)
                base64FilterStream.flush()
                outputStream.toString()
            }
        }
    }
}

New Code:

fun imageUriToBase64(context: Context, uri: Uri): String? {
    val contentResolver = context.contentResolver
    return contentResolver.openInputStream(uri)?.use { inputStream ->
        ByteArrayOutputStream().use { outputStream ->
            Base64OutputStream(outputStream, Base64.DEFAULT).use { base64FilterStream ->
                inputStream.copyTo(base64FilterStream)
                base64FilterStream.flush()
                outputStream.toString()
            }
        }
    }
}

from android-image-cropper.

Canato avatar Canato commented on May 28, 2024

com.theartofdev.edmodo:android-image-cropper:2.8.0
It works here pretty fine, you can check this library for you reference.

This was the main reason I fork from the old library @AbdulmalekAlshugaa , this was the way it work before OS 11.

Now with OS 11, this behaviour changed so the library was updated, not we need to update the usage of it too.
Please let's put all discussion about this on the same place: https://github.com/CanHub/Android-Image-Cropper/discussions/87

Sadly this is an Android OS change, but if anyone know a better fix for the latest OS, using scope storage and keeping it file drop a PR cause will help everyone =)

I will close so we focus the discussion on the same place
https://github.com/CanHub/Android-Image-Cropper/discussions/87

from android-image-cropper.

Canato avatar Canato commented on May 28, 2024

Please try the latest 3.0.0 release and let me know

from android-image-cropper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.