Last active
October 18, 2020 04:57
-
-
Save h-hub/d731f354d02483b1830a64262024c01e to your computer and use it in GitHub Desktop.
FileUploadController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@PreAuthorize("hasRole('ROLE_USER')") | |
@RequestMapping(value = "/image/upload", method = RequestMethod.POST, produces = { "application/json", | |
"application/xml" }) | |
@ResponseBody | |
@ResponseStatus(code = HttpStatus.CREATED) | |
public ImageDto uploadImage(@RequestParam(value = "imageFile", required = true) @ValidateImg MultipartFile image) { | |
String bucketName = "public-bucket-for-files"; | |
String imageUrl = imageService.uploadImage(image, bucketName); | |
ImageDto dto = new ImageDto(); | |
dto.url = imageUrl; | |
return dto; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment