Ejemplo n.º 1
0
 @RequestMapping("deleteObject.do")
 public @ResponseBody Object deleteObject(String bucketName, String key) {
   try {
     ossService.deleteObject(bucketName, key);
     return genSuccessResponse("", null);
   } catch (Exception e) {
     return genFailureResponse(e.getMessage());
   }
 }
Ejemplo n.º 2
0
 @RequestMapping("delBucket.do")
 public @ResponseBody Object deleteBucket(String bucketName) {
   try {
     ossService.deleteBucket(bucketName);
     return genSuccessResponse("", null);
   } catch (Exception e) {
     e.printStackTrace();
     return genFailureResponse(e.getMessage());
   }
 }
Ejemplo n.º 3
0
 @RequestMapping("getDownloadUrl.do")
 public @ResponseBody Object getDownloadUrl(@ModelAttribute DownloadUrlRequest request) {
   try {
     // Set the expired time to one hour later.
     request.setExpiration(new Date(System.currentTimeMillis() + AVAILABLE_PERIOD));
     String downloadUrl = ossService.generateUrlRequest(request);
     return genSuccessResponse("", factoryJson("url", downloadUrl));
   } catch (Exception e) {
     e.printStackTrace();
     return genFailureResponse(e.getMessage());
   }
 }
Ejemplo n.º 4
0
  @RequestMapping("uploadFile.do")
  public @ResponseBody Object uploadObject(
      @RequestParam("source") CommonsMultipartFile mFile,
      @ModelAttribute UploadSource uploadSource) {
    // System.out.println(mFile);
    try {
      // Set the expired time to one hour later.
      uploadSource.setInputStream(mFile.getInputStream());

      ObjectMetadata objectMetaData = new ObjectMetadata();
      objectMetaData.setContentType(mFile.getContentType());
      objectMetaData.setContentLength(mFile.getFileItem().getSize());

      uploadSource.setObjectMetaData(objectMetaData);

      ossService.uploadObject(uploadSource);
      // Thread.sleep(2000);

      return genSuccessResponse("", null);
    } catch (Exception e) {
      e.printStackTrace();
      return genFailureResponse(e.getMessage());
    }
  }