| | |
| | | package cn.gistack.resource.feign; |
| | | |
| | | import cn.gistack.resource.builder.oss.OssBuilder; |
| | | import cn.gistack.resource.entity.FormateTuEntity; |
| | | import cn.gistack.resource.entity.QieTuEntity; |
| | | import cn.gistack.resource.panoramaUtils.QietuResult; |
| | | import com.alibaba.fastjson.JSON; |
| | |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | |
| | | @Override |
| | | @PostMapping(UPLOAD_QIETU) |
| | | public R uploadQietu(QieTuEntity qieTuEntity) throws IOException { |
| | | // public R uploadQietu(HashMap<String,String> qietuHashMap,String resGuid) throws IOException { |
| | | HashMap<String,String> qietuHashMap = qieTuEntity.getQietuHashMap(); |
| | | System.err.println("切图的路径:"+qietuHashMap); |
| | | |
| | | String resGuid = qieTuEntity.getResGuid(); |
| | | |
| | | List<String> qieTuUrlList = new ArrayList<String>(); |
| | |
| | | |
| | | return R.data(result); |
| | | } |
| | | |
| | | @Override |
| | | @PostMapping(UPLOAD_FORMATETU) |
| | | public R uploadFormate(QieTuEntity qieTuEntity) throws IOException { |
| | | |
| | | ArrayList<FormateTuEntity> list = qieTuEntity.getList(); |
| | | |
| | | |
| | | // Set<String> mapKey = qietuHashMap.keySet(); |
| | | if(list != null && list.size()>0) { |
| | | for (FormateTuEntity item : list) { |
| | | |
| | | String picName = item.getPicName(); |
| | | String url = item.getLinshiUrl(); |
| | | Path qietuPath = Paths.get(url); |
| | | File qietufile = qietuPath.toFile(); |
| | | FileInputStream fileInputStream = new FileInputStream(qietufile); |
| | | BladeFile bladeFile = ossBuilder.template().putFile(picName, fileInputStream); |
| | | fileInputStream.close(); // 关闭文件流 |
| | | |
| | | String link = bladeFile.getLink(); |
| | | |
| | | // 格式化后的临时图片上传完成后删除临时文件 |
| | | if (qietufile.exists()) { |
| | | // 删除指定文件,不存在报异常 |
| | | FileUtils.forceDelete(qietufile); |
| | | } |
| | | |
| | | |
| | | item.setLinshiUrl(link); |
| | | |
| | | } |
| | | } |
| | | QieTuEntity result = new QieTuEntity(); |
| | | result.setList(list); |
| | | |
| | | return R.data(result); |
| | | } |
| | | |
| | | @PostMapping(value = UPLOAD_FILE) |
| | | public String uploadFile(String fileName, MultipartFile file) throws Exception{ |
| | | |
| | | // InputStream inputStream = new ByteArrayInputStream(bytes); |
| | | |
| | | BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream()); |
| | | |
| | | String link = bladeFile.getLink(); |
| | | if (link.indexOf("http://10.42.6.251:8082") != -1) { |
| | | link= link.replace("http://10.42.6.251:8082", "https://sk.hubeishuiyi.cn/gminio"); |
| | | } |
| | | return link; |
| | | } |
| | | } |