title: Aws s3 not taking MultipartFile and not working normal File upload to tomcat server after deploy and working on locally
body: <p>On uploading file to aws s3 bucket, its working fine locally. But when i deployed project on tomcat server its giving error to write <code>fileoutputstream</code> <strong>(permission denied)</strong></p>
  
  <p>Here is the image</p>
  
  <p><a href="https://i.stack.imgur.com/fstSl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fstSl.jpg" alt="enter image description here"></a></p>
  
  <p>Here is my code</p>
  
  <pre><code>private File convertMultiPartToFile(MultipartFile file) throws IOException {
          File convFile = new File(file.getOriginalFilename());
          FileOutputStream fos = new FileOutputStream(convFile);
          fos.write(file.getBytes());
          fos.close();
          return convFile;
      }
  
      private String generateFileName(MultipartFile multiPart) {
          return new Date().getTime() + "-" + multiPart.getOriginalFilename().replace(" ", "_");
      }
  
      private void uploadFileTos3bucket(String fileName, File file) {
          s3client.putObject(
                  new PutObjectRequest(bucketName, fileName, file).withCannedAcl(CannedAccessControlList.PublicRead));
      }
  </code></pre>
  
  <p>and when i change to File to <code>Multipartfile</code> its show's me this error</p>
  
  <p><a href="https://i.stack.imgur.com/Kajsg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kajsg.png" alt="enter image description here"></a></p>
  
  <p>Also if i am uploading multipart directly to s3 bucket, its giving error to cast it into file. And if i am casting file to multipart than its giving (I/O) Exception</p>