title: Azure storage through java MVC web site
body: <p>I have a java web app using Spring and hibernate framework. I am moving this web app on azure. In on premises web app there is one functionality in which I upload the image first in a temporary folder in C: and later access that file for application. The location of uploaded file is also stored in DB for further references. I have defined the base-path for uploading file in a properties file and accessing through it in controller as well as service layer for creating the directory, file name and file path.</p>
  
  <p>Can any tell me how to do the same in azure using azure storage? Any help is appreciated.</p>
  
  <p>Code in properties file:</p>
  
  <pre><code># Base File Path for Uploading Files 
  fileupload.basepath=C:/webApp
  </code></pre>
  
  <p>Code for creating temporary folder</p>
  
  <pre><code>    @RequestMapping(value = "/file/upload", method = RequestMethod.POST)
  public @ResponseBody
  String upload(MultipartHttpServletRequest request,
          HttpServletResponse response) {
  
      // 0. notice, we have used MultipartHttpServletRequest
  
      // 1. get the files from the request object
      Iterator&lt;String&gt; itr = request.getFileNames();
  
      MultipartFile mpf = request.getFile(itr.next());
  
      if (!CommonUtil.isNull(mpf)) {
          if (mpf.getSize() &gt; ProductCommonConstants.MAX_FILE_UPLOAD_SIZE_IN_BYTES) {
              return CommonConstants.STR_FAILURE;
          }
  
      }
  
      long fileName = Calendar.getInstance().getTimeInMillis();
  
      final String modelImageDirPath = baseUploadFilePath + "/"
              + CommonConstants.TEMP_FILE_NAME;
  
      // Check for folder existence
      final File modelImageDir = new File(modelImageDirPath);
      if (!modelImageDir.exists()) {
          // Create the directory
          modelImageDir.mkdirs();
      }
  
      InputStream is = null;
      FileOutputStream fos = null;
  
      try {
          String contentType = mpf.getContentType();
  
          if (contentType != null) {
  
              is = new DataInputStream(mpf.getInputStream());
  
              // just temporary save file info
              File file = new File(modelImageDirPath + "/" + fileName);
  
              fos = new FileOutputStream(file);
  
              // Write to the file
              IOUtils.copy(is, fos);
          }
  
      } catch (FileNotFoundException ex) {
  
      } catch (IOException ex) {
  
      } finally {
  
          try {
              if (fos != null) {
                  fos.close();
              }
              if (is != null) {
                  is.close();
              }
          } catch (IOException ignored) {
              // Log the Exception
  
          }
      }
  
      // 2. send it back to the client as &lt;img&gt; that calls get method
      // we are using getTimeInMillis to avoid server cached image
  
      return "/service/common/file/get/" + fileName;
  
  }
  
  }
  </code></pre>