I am trying to upload an image to S3 using a presigned upload URL, which has content type set to `image/jpeg` and method at PUT. Post upload, when I try to access the image on S3, it seems to be corrupt and the size is larger than the local image file. My code is below.

```
        URL url = new URL(uploadUrl);
        HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
        httpCon.setDoOutput(true);
        httpCon.setRequestMethod("PUT");
        httpCon.setRequestProperty("Content-Type", "image/jpeg");
        OutputStreamWriter out = new OutputStreamWriter(httpCon.getOutputStream());

        RandomAccessFile f = new RandomAccessFile(imagePath, "r");
        int length = (int) imagePath.length();
        byte[] imageData = new byte[length];
        f.readFully(imageData);
        String data = new String(imageData);
        out.write(data);
        out.close();

        int responseCode = httpCon.getResponseCode();
        return (responseCode == HttpStatus.SC_OK);

```