Package com.almis.awe.controller
Class UploadController
java.lang.Object
com.almis.awe.config.ServiceConfig
com.almis.awe.controller.UploadController
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
Manage template request
-
Constructor Summary
ConstructorDescriptionUploadController
(FileService fileService, BroadcastService broadcastService, com.fasterxml.jackson.databind.ObjectMapper mapper, BaseConfigProperties baseConfigProperties) Autowired constructor -
Method Summary
Modifier and TypeMethodDescriptionHandle upload errorvoid
handleFileUpload
(String token, org.springframework.web.multipart.MultipartFile file, String address, String destination, String uploadIdentifier) Upload a fileHandle upload errorhandleMaxSizeException
(org.springframework.web.multipart.MaxUploadSizeExceededException exc) Handle upload errorMethods inherited from class com.almis.awe.config.ServiceConfig
containsBean, getApplicationContext, getBean, getBean, getElements, getLocale, getLocale, getProperty, getProperty, getRequest, getSession, setApplicationContext
-
Constructor Details
-
UploadController
@Autowired public UploadController(FileService fileService, BroadcastService broadcastService, com.fasterxml.jackson.databind.ObjectMapper mapper, BaseConfigProperties baseConfigProperties) Autowired constructor- Parameters:
fileService
- File servicebroadcastService
- Broadcast servicemapper
- Object mapperbaseConfigProperties
- Base config properties
-
-
Method Details
-
handleFileUpload
@PostMapping(value="/upload", consumes="multipart/form-data") @ResponseStatus(OK) public void handleFileUpload(@RequestHeader("Authorization") String token, @RequestParam("file") org.springframework.web.multipart.MultipartFile file, @RequestParam("address") String address, @RequestParam("destination") String destination, @RequestParam("u") String uploadIdentifier) throws AWException, IOException Upload a file- Parameters:
token
- Request tokenfile
- File to uploadaddress
- Component addressdestination
- Destination folderuploadIdentifier
- Uploader identifier- Throws:
AWException
- Error uploading fileIOException
-
handleAWException
@ExceptionHandler(AWException.class) @ResponseStatus(NOT_ACCEPTABLE) public String handleAWException(AWException exc) Handle upload error- Parameters:
exc
- Exception to handle- Returns:
- Response error
-
handleMaxSizeException
@ExceptionHandler(org.springframework.web.multipart.MaxUploadSizeExceededException.class) @ResponseStatus(PAYLOAD_TOO_LARGE) public String handleMaxSizeException(org.springframework.web.multipart.MaxUploadSizeExceededException exc) Handle upload error- Parameters:
exc
- Exception to handle- Returns:
- Response error
-
handleIOException
@ExceptionHandler({org.springframework.web.multipart.MultipartException.class,org.apache.commons.fileupload2.core.FileUploadException.class,java.lang.Exception.class}) @ResponseStatus(NOT_ACCEPTABLE) public String handleIOException(Exception exc) Handle upload error- Parameters:
exc
- Exception to handle- Returns:
- Response error
-