How to have ASP.Net Webpage read bytes from Java Android client?
<p>I'm trying to upload images to External MS SQL database using android phone. I'm using Java HttpClient to send array of bytes to web server or web page. I don't know how I should approach this. The web page should be in ASP.net. I'm fairly new to ASP.Net. I did intensive research on how to read in a byte array using ASP.Net and still don't have an answer. I want my webpage or server to read in the bytes and store them into database.</p>

<p>Below is my Java function (it is not tested yet since I don't have a way to read bytes yet) that I want to use to send the bytes. But I have no idea how to read them in on website side. Any suggestions would be appreciated. If you guys see that I'm doing something wrong also it would be appreciated if you let me know and tell me how I should fix it. Please be specific since I'm really new to this and don't really know much about web pages. Thanks. </p>

<pre><code>    private void sendImagesToServer() throws Exception
{
    ImageItem image;
    HttpURLConnection conn = null;
    ImageIterator iterator;
    DataOutputStream dos;
    byte[] byteArray;
    iterator = new ImageIterator(imageAdapter);
    String uploadUrl;

    while(iterator.hasNext())
    {
        image = iterator.getNext();
        Uri uri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, Integer.toString(image.id));

        Bitmap bmp=BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bmp.compress(Bitmap.CompressFormat.JPEG, 100, stream);
        byteArray = stream.toByteArray();

        uploadUrl = "http://localhost:63776/SQLScript.aspx";

        // Send request
        try {
            // Configure connection

            URL url = new URL(uploadUrl);
            conn = (HttpURLConnection) url.openConnection();
            conn.setDoInput(true);
            conn.setDoOutput(true);
            conn.setUseCaches(false);
            conn.setRequestMethod("PUT");
            conn.setRequestProperty("Connection", "Keep-Alive");

            dos = new DataOutputStream(conn.getOutputStream());
            dos.write(byteArray, 0, byteArray.length);
            dos.flush();
            dos.close();

            // Read response
            try {
                if (conn.getResponseCode() == 200) {
                    Toast.makeText(this,"Yay, We Got 200 as Response Code",Toast.LENGTH_SHORT).show();
                }
            } catch (IOException ioex) {
                ioex.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }

        } finally{

        }   

    }

}   
</code></pre>
