| | |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.oss.OssTemplate; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | |
| | | public class OssFileController { |
| | | |
| | | @Autowired |
| | | private NcProgramApprovedService ncProgramApprovedService; |
| | | @Autowired |
| | | private OssFileCommonService ossFileCommonService; |
| | | @Autowired |
| | | private OssTemplate ossTemplate; |
| | | @Autowired |
| | | private ParamService paramService; |
| | | /** |
| | |
| | | */ |
| | | @GetMapping("file-content") |
| | | @ApiOperationSupport(order = 3) |
| | | @Operation(summary = "待办任务数量查询", description = "待办任务数量查询") |
| | | @Operation(summary = "获取文件文本内容", description = "获取文件文本内容") |
| | | public R<String> fileContent(String ossFileName) { |
| | | if(StringUtils.isBlank(ossFileName)){ |
| | | throw new RuntimeException("文件名为空"); |
| | |
| | | } |
| | | |
| | | |
| | | @GetMapping("file-bytes") |
| | | @ApiOperationSupport(order = 3) |
| | | @Operation(summary = "获取文件字节", description = "获取文件字节") |
| | | public void fileBytes(String ossFileName, HttpServletResponse response) throws IOException { |
| | | if(StringUtils.isBlank(ossFileName)){ |
| | | throw new RuntimeException("文件名为空"); |
| | | } |
| | | //ossTemplate.fileLink() |
| | | try(InputStream ins = ossTemplate.statFileStream(ossFileName);){ |
| | | response.getOutputStream().write(IOUtils.toByteArray(ins)); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("file-link") |
| | | @ApiOperationSupport(order = 3) |
| | | @Operation(summary = "获取文件字节", description = "获取文件字节") |
| | | public R<String> fileLink(String ossFileName) throws IOException { |
| | | if(StringUtils.isBlank(ossFileName)){ |
| | | throw new RuntimeException("文件名为空"); |
| | | } |
| | | String link = ossTemplate.fileLink(ossFileName); |
| | | return R.data(link); |
| | | } |
| | | } |