|
@@ -22,6 +22,7 @@ import com.pig4cloud.common.minio.vo.MinioItem;
|
|
|
import com.pig4cloud.common.minio.vo.MinioObject;
|
|
|
import io.minio.messages.Bucket;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -48,60 +49,65 @@ public class MinioEndpoint {
|
|
|
/**
|
|
|
* Bucket Endpoints
|
|
|
*/
|
|
|
+ @SneakyThrows
|
|
|
@PostMapping("/bucket/{bucketName}")
|
|
|
- public Bucket createBucker(@PathVariable String bucketName) throws Exception {
|
|
|
+ public Bucket createBucker(@PathVariable String bucketName) {
|
|
|
|
|
|
template.createBucket(bucketName);
|
|
|
return template.getBucket(bucketName).get();
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
@GetMapping("/bucket")
|
|
|
- public List<Bucket> getBuckets() throws Exception {
|
|
|
+ public List<Bucket> getBuckets() {
|
|
|
return template.getAllBuckets();
|
|
|
}
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
@GetMapping("/bucket/{bucketName}")
|
|
|
- public Bucket getBucket(@PathVariable String bucketName) throws Exception {
|
|
|
+ public Bucket getBucket(@PathVariable String bucketName) {
|
|
|
return template.getBucket(bucketName).orElseThrow(() -> new IllegalArgumentException("Bucket Name not found!"));
|
|
|
}
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
@DeleteMapping("/bucket/{bucketName}")
|
|
|
@ResponseStatus(HttpStatus.ACCEPTED)
|
|
|
- public void deleteBucket(@PathVariable String bucketName) throws Exception {
|
|
|
-
|
|
|
+ public void deleteBucket(@PathVariable String bucketName) {
|
|
|
template.removeBucket(bucketName);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Object Endpoints
|
|
|
*/
|
|
|
-
|
|
|
+ @SneakyThrows
|
|
|
@PostMapping("/object/{bucketName}")
|
|
|
- public MinioObject createObject(@RequestBody MultipartFile object, @PathVariable String bucketName) throws Exception {
|
|
|
+ public MinioObject createObject(@RequestBody MultipartFile object, @PathVariable String bucketName) {
|
|
|
String name = object.getOriginalFilename();
|
|
|
template.putObject(bucketName, name, object.getInputStream(), object.getSize(), object.getContentType());
|
|
|
return new MinioObject(template.getObjectInfo(bucketName, name));
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
@PostMapping("/object/{bucketName}/{objectName}")
|
|
|
- public MinioObject createObject(@RequestBody MultipartFile object, @PathVariable String bucketName, @PathVariable String objectName) throws Exception {
|
|
|
+ public MinioObject createObject(@RequestBody MultipartFile object, @PathVariable String bucketName, @PathVariable String objectName) {
|
|
|
template.putObject(bucketName, objectName, object.getInputStream(), object.getSize(), object.getContentType());
|
|
|
return new MinioObject(template.getObjectInfo(bucketName, objectName));
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ @SneakyThrows
|
|
|
@GetMapping("/object/{bucketName}/{objectName}")
|
|
|
- public List<MinioItem> filterObject(@PathVariable String bucketName, @PathVariable String objectName) throws Exception {
|
|
|
+ public List<MinioItem> filterObject(@PathVariable String bucketName, @PathVariable String objectName) {
|
|
|
|
|
|
return template.getAllObjectsByPrefix(bucketName, objectName, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
@GetMapping("/object/{bucketName}/{objectName}/{expires}")
|
|
|
- public Map<String, Object> getObject(@PathVariable String bucketName, @PathVariable String objectName, @PathVariable Integer expires) throws Exception {
|
|
|
+ public Map<String, Object> getObject(@PathVariable String bucketName, @PathVariable String objectName, @PathVariable Integer expires) {
|
|
|
Map<String, Object> responseBody = new HashMap<>(8);
|
|
|
// Put Object info
|
|
|
responseBody.put("bucket", bucketName);
|
|
@@ -111,9 +117,10 @@ public class MinioEndpoint {
|
|
|
return responseBody;
|
|
|
}
|
|
|
|
|
|
- @DeleteMapping("/object/{bucketName}/{objectName}/")
|
|
|
+ @SneakyThrows
|
|
|
@ResponseStatus(HttpStatus.ACCEPTED)
|
|
|
- public void deleteObject(@PathVariable String bucketName, @PathVariable String objectName) throws Exception {
|
|
|
+ @DeleteMapping("/object/{bucketName}/{objectName}/")
|
|
|
+ public void deleteObject(@PathVariable String bucketName, @PathVariable String objectName) {
|
|
|
|
|
|
template.removeObject(bucketName, objectName);
|
|
|
}
|