Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6191775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:49:32+00:00 2026-05-24T02:49:32+00:00

I am developing an Android app that uploads image (jpg) to AWS S3. The

  • 0

I am developing an Android app that uploads image (jpg) to AWS S3. The image is being uploaded but I am unable to open it using web browser: the image is either invalid or opened as a string.

//skipping error handling for simplicity

InputStream is = Utils.streamFromUri(this, uri);
byte[] buffer = new byte[FileUtils.getInputSize(is)];
...
//is is restored at this point
is.read(buffer);
String data = new String(buffer);
S3.createObjectForBucket(bucketName, objectName, data)

Can you please share a working code for upload or give some directions on how to resolve this?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:49:33+00:00Added an answer on May 24, 2026 at 2:49 am

    First file is just 0 filled. Second file is not a jpeg but appears to be a result of some kind of transformation (there is some photo data in it). There should be no issue with upload under normal circumstances. If you provide specifics on how you uploaded them (code or tool) we can go from there.


    Update

    Your code to get data for upload is probably not going to work. I don’t know specifics about your utilities but when you do

    FileUtils.getInputSize(is)
    

    it probably reads the entire stream, so you end up at the end of it and read nothing for upload. I highly recommend that you use Apache Commons IO to read data. And you can get size of it after it’s read into memory.


    Update 2

    You are using byte to string conversion. From String(byte[]) documentation

    Constructs a new String by decoding the specified array of bytes using 
    

    the platform’s default charset.

    Since you use binary data, it’s getting transformed. That actually also can be seen from your second file which start with ef bf bd which is Unicode replacement character. So refrain from using string for storing binary data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an Android App that should send an image to my ASP.NET Web
I am developing an Android app that connects to the Facebook Open Graph via
I am developing an Android App that gets some data from a web server,
I'm developing an Android APP that connects to Google Calendar using GData API for
I am currently developing an Android app that is using a remote MySQL database
I'm developing an Android app that fetches a web page from a website which
I am developing an Android app that ties into a web app thats also
I'm currently developing an Android application that fetches images using http requests. It would
i am developing an android app that fetches an RSS feed, now i want
I am developing an Android app that needs to receive specific informations for each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.