|
|
|
@ -1,18 +1,22 @@
|
|
|
|
|
package org.springblade.resource.feign; |
|
|
|
|
|
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.oss.OssTemplate; |
|
|
|
|
import org.springblade.core.oss.model.BladeFile; |
|
|
|
|
import org.springblade.core.sms.model.SmsResponse; |
|
|
|
|
import org.springblade.core.tenant.annotation.NonDS; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
import org.springblade.resource.builder.OssBuilder; |
|
|
|
|
import org.springframework.http.MediaType; |
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestPart; |
|
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
|
@NonDS |
|
|
|
|
@RestController |
|
|
|
|
@AllArgsConstructor |
|
|
|
@ -25,16 +29,19 @@ public class OssClient implements IOssClient {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@PostMapping(name = FILE_UPLOAD,consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
|
|
|
|
public R<BladeFile> fileUpload(@RequestPart("file") MultipartFile file) { |
|
|
|
|
|
|
|
|
|
@PostMapping(name = FILE_UPLOAD, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
|
|
|
|
public R<BladeFile> fileUpload(@RequestPart("file") MultipartFile file, @RequestParam(value = "bucket", required = false) String bucket) { |
|
|
|
|
|
|
|
|
|
if (StringUtil.isBlank(bucket)) { |
|
|
|
|
bucket = "op-logs"; |
|
|
|
|
} |
|
|
|
|
OssTemplate minio = ossBuilder.template("minio", "000000"); |
|
|
|
|
if(!minio.bucketExists("op-logs")){ |
|
|
|
|
if (!minio.bucketExists(bucket)) { |
|
|
|
|
// 创建bucket
|
|
|
|
|
minio.makeBucket("op-logs"); |
|
|
|
|
log.info(">>>>>>>>>>>>>>>>>>> bucket {}", bucket); |
|
|
|
|
minio.makeBucket(bucket); |
|
|
|
|
} |
|
|
|
|
return R.data(minio.putFile("op-logs",file.getName(),file)); |
|
|
|
|
return R.data(minio.putFile(bucket, file.getName(), file)); |
|
|
|
|
|
|
|
|
|
//return R.data(ossBuilder.template("minio","000000").putFile(file));
|
|
|
|
|
} |
|
|
|
|