title: Receiving byte array thats a pdf. Want to convert it to multipart part file so I can upload to s3. Trying to get uploadFile method to accept bytes?
body: <p>The method I am trying to refactor I would like it to accept bytes instead of multipart file. </p>
  
  <pre><code>public String uploadFile(MultipartFile multipartFile) throws IOException {
  
      String fileUrl = "";
      try {
          File file = convertMultiPartToFile(multipartFile);
          String fileName = generatedFileName(multipartFile);
          fileUrl = endpointUrl + "/" + bucketName + "/" + fileName;
          uploadFileTos3Bucket(fileName, file);
          file.delete();
  } catch ..........
  </code></pre>
  
  <p>method to upload to S3</p>
  
  <pre><code>private void uploadFileTos3Bucket(String fileName, File file) {
      s3client.putObject(new PutObjectRequest(bucketName, fileName, file));
  
  }
  
  private String generatedFileName(MultipartFile multipart) {
      return new Date().getTime() + "-" + multipart.getOriginalFilename().replace(" ", "_");
  }
  
  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;
  }
  </code></pre>