5 changed files with 31 additions and 24 deletions
@ -1,41 +1,48 @@ |
|||||||
package org.springblade.resource.feign; |
package org.springblade.resource.feign; |
||||||
|
|
||||||
import lombok.AllArgsConstructor; |
import lombok.AllArgsConstructor; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
import org.springblade.core.oss.OssTemplate; |
import org.springblade.core.oss.OssTemplate; |
||||||
import org.springblade.core.oss.model.BladeFile; |
import org.springblade.core.oss.model.BladeFile; |
||||||
import org.springblade.core.sms.model.SmsResponse; |
import org.springblade.core.sms.model.SmsResponse; |
||||||
import org.springblade.core.tenant.annotation.NonDS; |
import org.springblade.core.tenant.annotation.NonDS; |
||||||
import org.springblade.core.tool.api.R; |
import org.springblade.core.tool.api.R; |
||||||
|
import org.springblade.core.tool.utils.StringUtil; |
||||||
import org.springblade.resource.builder.OssBuilder; |
import org.springblade.resource.builder.OssBuilder; |
||||||
import org.springframework.http.MediaType; |
import org.springframework.http.MediaType; |
||||||
import org.springframework.web.bind.annotation.PostMapping; |
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.RequestPart; |
||||||
import org.springframework.web.bind.annotation.RestController; |
import org.springframework.web.bind.annotation.RestController; |
||||||
import org.springframework.web.multipart.MultipartFile; |
import org.springframework.web.multipart.MultipartFile; |
||||||
|
|
||||||
|
@Slf4j |
||||||
@NonDS |
@NonDS |
||||||
@RestController |
@RestController |
||||||
@AllArgsConstructor |
@AllArgsConstructor |
||||||
public class OssClient implements IOssClient { |
public class OssClient implements IOssClient { |
||||||
|
|
||||||
/** |
/** |
||||||
* 对象存储构建类 |
* 对象存储构建类 |
||||||
*/ |
*/ |
||||||
private final OssBuilder ossBuilder; |
private final OssBuilder ossBuilder; |
||||||
|
|
||||||
|
|
||||||
@Override |
@Override |
||||||
@PostMapping(name = FILE_UPLOAD,consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
@PostMapping(name = FILE_UPLOAD, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
||||||
public R<BladeFile> fileUpload(@RequestPart("file") MultipartFile file) { |
public R<BladeFile> fileUpload(@RequestPart("file") MultipartFile file, @RequestParam(value = "bucket", required = false) String bucket) { |
||||||
|
|
||||||
|
if (StringUtil.isBlank(bucket)) { |
||||||
OssTemplate minio = ossBuilder.template("minio", "000000"); |
bucket = "op-logs"; |
||||||
if(!minio.bucketExists("op-logs")){ |
} |
||||||
// 创建bucket
|
OssTemplate minio = ossBuilder.template("minio", "000000"); |
||||||
minio.makeBucket("op-logs"); |
if (!minio.bucketExists(bucket)) { |
||||||
} |
// 创建bucket
|
||||||
return R.data(minio.putFile("op-logs",file.getName(),file)); |
log.info(">>>>>>>>>>>>>>>>>>> bucket {}", bucket); |
||||||
|
minio.makeBucket(bucket); |
||||||
//return R.data(ossBuilder.template("minio","000000").putFile(file));
|
} |
||||||
} |
return R.data(minio.putFile(bucket, file.getName(), file)); |
||||||
|
|
||||||
|
//return R.data(ossBuilder.template("minio","000000").putFile(file));
|
||||||
|
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue