title: upload image to facebook from arraylist of inputstream type in android?
body: <p>I can create input stream from url and successfully uploading image to facebook.</p>
  
  <pre><code>HttpURLConnection conn = (HttpURLConnection) uploadFileUrl.openConnection();
  conn.setDoInput(true);
  conn.connect();
  int length = conn.getContentLength();
  imgData = new byte[length];
  InputStream is = conn.getInputStream();
  </code></pre>
  
  <p>but i am geting Inputstream from bundle like-</p>
  
  <pre><code>Bundle extras = getIntent().getExtras();
  if (extras != null) {
      int img_pos = extras.getInt("image_pos");
      mInputStream = com.LiveWallapper.LiveWallapperActivity.mInput.get(img_pos);
      System.out.println("input in readbytes++++++++++++++" + mInputStream);
  }
  </code></pre>
  
  <p>and wants to upload image in Example.java like-</p>
  
  <pre><code>params.putString("method", "photos.upload");
  params.putByteArray("picture", readBytes(mInputStream));
  mAsyncRunner.request(null, params, "POST", new SampleUploadListener(), null);
  </code></pre>
  
  <p>and readBytes method is--</p>
  
  <pre><code>public byte[] readBytes(InputStream inputStream) throws IOException {
      // this dynamically extends to take the bytes you read
      ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
      // this is storage overwritten on each iteration with bytes
  
      // we need to know how may bytes were read to write them to the
      // byteBuffer
  
      int bufferSize = 10000;//i can not getcontent length from inputstream so i give //10000, pls help
      byte[] imgData = new byte[bufferSize];
      int len = 0;
  
      while ((len = inputStream.read(imgData)) != -1) {
          byteBuffer.write(imgData, 0, len);
      }
  
      // and then we can return your byte array.
      return byteBuffer.toByteArray();
  }
  </code></pre>