title: spring boot cloud storage file upload
body: <p>upload file to google cloud storage from spring boot controller. please provide me a code.</p>
  
  <p>so far i came up a code like this</p>
  
  <pre><code>@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
  @SuppressWarnings("deprecation")
  public String uploadFile( @RequestParam("files")  Part filePart ) throws IOException {
  
      private static Storage storage = null;
  
      final String bucketName = "mcqimages";
      DateTimeFormatter dtf = DateTimeFormat.forPattern("-YYYY-MM-dd-HHmmssSSS");
      DateTime dt = DateTime.now(DateTimeZone.UTC);
      String dtString = dt.toString(dtf);
      String fileName = "C:\\Users\\sachinthah\\Downloads\\821092.png";
      fileName = filePart.getSubmittedFileName() + dtString;
  
      // the inputstream is closed by default, so we don't need to close it here
      BlobInfo blobInfo =
              storage.create(
                      BlobInfo
                              .newBuilder(bucketName, fileName)
                              // Modify access list to allow all users with link to read file
                              .setAcl(new ArrayList&lt;&gt;(Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER))))
                              .build(),
                      filePart.getInputStream());
  
      return blobInfo.getMediaLink();
  }
  </code></pre>