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

  • Home
  • SEARCH
  • 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 6335693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:54:22+00:00 2026-05-24T18:54:22+00:00

currently I’m using kSoap to publish data to C# web services. Now I’ve come

  • 0

currently I’m using kSoap to publish data to C# web services. Now I’ve come to the part where I need to upload images from my machine using Base64Binary. I searched everywehre internet but couldn’t come up with a proper solution.

there is a solution with external Base64 class example but I’m interested in native solution as there is a API from Android 2.2.

Since I’m a newbie I couldn’t do it myself. Basically I have a sd card file path of images, I want to convert them into Base64 format to upload.

Hope someone can help me or direct me to proper documents.

Thanks in advance.

  • 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-24T18:54:23+00:00Added an answer on May 24, 2026 at 6:54 pm

    I figured out the issue

    String Image64 = null;
    
    
            try {
                Image64 = Base64.encodeToString((getBytesFromFile(new File(path))), DEFAULT);
    
            } catch (IOException e) {
                e.printStackTrace();
    
            }
    
    //encording
        public static byte[] getBytesFromFile(File file) throws IOException {
            InputStream is = new FileInputStream(file);
    
            // Get the size of the file
            long length = file.length();
    
            // You cannot create an array using a long type.
            // It needs to be an int type.
            // Before converting to an int type, check
            // to ensure that file is not larger than Integer.MAX_VALUE.
            if (length > Integer.MAX_VALUE) {
                // File is too large
            }
    
            // Create the byte array to hold the data
            byte[] bytes = new byte[(int)length];
    
            // Read in the bytes
            int offset = 0;
            int numRead = 0;
            while (offset < bytes.length
                   && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
                offset += numRead;
            }
    
            // Ensure all the bytes have been read in
            if (offset < bytes.length) {
                throw new IOException("Could not completely read file "+file.getName());
            }
    
            // Close the input stream and return bytes
            is.close();
            return bytes;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am using a pretty basic function to pre-load images: function preload(arrayOfImages) {
Currently I am download data from a server and I have this line to
Currently I'm doing some unit tests which are executed from bash. Unit tests are
Currently I know of only two ways to cache data (I use PHP but
Currently, I am developing a product that does fairly intensive calculations using MS SQL
Currently my query is very heavy, the table (table A) I need to update
Currently i'm having trouble using two functions in my -(void)viewDidLoad , both of these
Currently I have a date in my clients data table and it is stored
Currently we use log4net of version 1.2.10.0 and we should start using some 3rd
Currently we are using Trac . Tickets are good for tracking tasks and related

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.