Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

268
Views
how to resolve java.io.FileNotFoundException when trying to get inputstream from AWS url

my main goal is to get the orientation of a image which I get from AWS, part of the code is to first get the imputStream for which I need to pass the URI, I am doing Uri.parse(url) to get the uri and when I try to get URI I get

java.io.FileNotFoundException: No content provider

URL passed:

https://xxx-2.amazonaws.com/YRINWoUKBOW97VXvpnRelWioT2r2/6d95054e-8a6c-4a61-a4ff-18f63aa187b4/1/thumbnail.png?X-Amz-Algorithm=AWS4-HMAC-xx&X-Amz-Date=20220221T203050Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1800&X-Amz-Credential=AKIAJGEUAZB7E5XX6NPA%2F20220221%2Feu-west-2%2Fs3%xx&X-Amz-Signature=d3839d925efc6fffff417e25af1e6bad28ed10ef27d1c4460d20470

error

java.io.FileNotFoundException: No content provider: https://xxx2.amazonaws.com/YRINWoUKBOW97VXvpnRelWioT2r2/6d95054e-8a6c-4a61-a4ff-18f63aa187b4/1/thumbnail.png?X-Amz-Algorithm=AWS4-HMAC-xxx&X-Amz-Date=20220221T203050Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1800&X-Amz-Credential=AKIAJGEUAZB7E5XX6NPA%2F20220221%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Signature=d3839dffff925efc6417e25aff414d76b8ed10ef27d1c4460d20470

this is my code

private fun getExifOrientationFromURI(context: Context, url: String): Int {
        var orientation: Int = 1
        try {
    context.contentResolver.openInputStream(Uri.parse(url)).use { inputStream -> //ERROR IS AT THIS LINE 
                if(inputStream == null) return  orientation
                val exif = ExifInterface(inputStream)
                orientation =
                    exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)
            }
        } catch (e: IOException) {
            e.printStackTrace()
        }
        return orientation
    }

what am I doing wrong?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

openInputStream() on ContentResolver does not support http or https URLs, only file, content, and android.resource Uri values. You need to use an HTTPS API for your URL, such as OkHttp.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!