title: Uploading an image from gallery to s3 bucket - Creating a file object?
body: <p>AWS SDK requires a <code>File</code> object for uploading data to a bucket. I'm having trouble creating a File object required by <code>transferUtility.upload</code>. I know <code>new File(selectedImageUri.getPath())</code> does not work. I've tried reading about how to make a file from a uri, but there doesn't seem to be an easy way of doing that. Should I be using something other than <code>TransferUtility</code>? </p>
  
  <pre><code>public class SettingsActivity extends AppCompatActivity {
      ...
  
      private class ChangeSettingsTask extends AsyncTask&lt;Void, Void, Boolean&gt; {
  
      public void uploadData(File image) {
          TransferUtility transferUtility =
                  TransferUtility.builder()
                          .defaultBucket("some-bucket")
                          .context(getApplicationContext())
                          .s3Client(new AmazonS3Client( new BasicAWSCredentials( "something", "something") ))
                          .build();
  
          TransferObserver uploadObserver =
                  transferUtility.upload("somefile.jpg", image);
  
          ...
      }
  
      @Override
      protected void onActivityResult(int reqCode, int resultCode, Intent data) {
          super.onActivityResult(reqCode, resultCode, data);
  
          if (resultCode == RESULT_OK) {
              Uri selectedImageUri = data.getData();
              uploadData(new File(selectedImageUri.getPath()));
          }
      }
  }
  </code></pre>