title: How to convert the uri to inputStream data and upload the stream data into server?
body: <p>I am working the task in picking the file from the gallery and upload the picked file to the server.</p>
  
  <pre><code>    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
     super.onActivityResult(requestCode, resultCode, data);
     if (resultCode == Activity.RESULT_OK) {
         if (requestCode == PICK_FILE_REQUEST) {
             if (data != null) {
                 //no data present
                 Uri uri = data.getData();
                String filePath = data.getData().getPath();
          //       String path = uri.getPath();
                 file = new File(filePath);
  
                 String name = getContentName(getContentResolver(), uri);
                 try {
                     InputStream inStream = getContentResolver().openInputStream(uri);
  
                 } catch (FileNotFoundException e) {
                     e.printStackTrace();
                 }
                 try {
                     bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
  
                 } catch (IOException e) {
                     e.printStackTrace();
                 }
  
                 LinearLayout linearLayout = new LinearLayout(this);
                 linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                         LinearLayout.LayoutParams.WRAP_CONTENT));
                 linearLayout.setOrientation(LinearLayout.VERTICAL);
  
                 ImageView imageView = new ImageView(this);
                 imageView.setImageBitmap(bitmap);
                 attachFile.addView(imageView);
  
  
                 TextView textView = new TextView(this);
                 textView.setText(name);
                 attachFile.addView(textView);
  
                 return;
             }
  
         }
     }
  </code></pre>
  
  <p>I poicked the file by using intent </p>
  
  <pre><code> Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
         intent.setType("*/*");
         intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
         //intent.addFlags(ST)
         startActivityForResult(Intent.createChooser(intent, "Choose File to Upload.."), PICK_FILE_REQUEST);
  </code></pre>
  
  <p>My issue is the uri data is converted the inputStream but i am using the ion library in that inputstream files cannot be uploaded to server.
  How to convert the inputStream to outputstream to save in getCacheDir().I refered this site <a href="https://stackoverflow.com/questions/43762230/how-to-get-the-file-path-for-the-picked-files-from-the-external-storage-in-andro">How to get the file path for the picked files from the external storage in android?</a> </p>
  
  <p>Please help me how to upload the InputStream data into the ion library.</p>