save image to aws s3 , if image exists replace the image
<p>Hi i want to save image to s3 but i done it recently , while uploading the image there is some warning showing on the console.How to resolve it..
And if the image exists i want to replace the image</p>

<pre><code>public String saveImage(MultipartFile file, String imageName) {
    try {
        String bucketName = "bucket";
        AmazonS3 s3client = new AmazonS3Client(
                new BasicAWSCredentials("*****", "******"));
        TransferManager transferManager = new TransferManager(s3client);
        // Otherwise: (Service: Amazon S3; Status Code: 301; Error Code:
        // PermanentRedirect)
        // s3client.setRegion(Region.getRegion(Regions.EU_WEST_1));
        ObjectMetadata objectMetadata = new ObjectMetadata();
        objectMetadata.setContentDisposition("attachment; filename=" + file.getOriginalFilename());
        Upload upload = transferManager.upload(bucketName, imageName, file.getInputStream(), objectMetadata);
        upload.waitForUploadResult();
        return "https://path-region/" + bucketName + "/" + imageName;
    } catch (Exception e) {
        return "You failed to upload " + e.getMessage();
    }
}




10:31:00,313 WARN  [com.amazonaws.services.s3.AmazonS3Client] (s3-transfer-manag
er-worker-1) No content length specified for stream data.  Stream contents will
be buffered in memory and could result in out of memory errors.
</code></pre>