| | |
| | | import com.dji.sample.media.model.MediaFileEntity; |
| | | import com.dji.sample.media.model.MediaFileQueryParam; |
| | | import com.dji.sample.media.service.IFileService; |
| | | import com.dji.sample.media.util.ImageDownloaderAndCompressor; |
| | | import com.drew.imaging.ImageProcessingException; |
| | | import org.apache.ibatis.annotations.Update; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.servlet.http.HttpServletResponseWrapper; |
| | | |
| | | import java.awt.*; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.URL; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.dji.sample.component.AuthInterceptor.TOKEN_CLAIM; |
| | | import static com.dji.sample.media.util.ImageDownloaderAndCompressor.*; |
| | | |
| | | /** |
| | | * @author sean |
| | |
| | | @RequestParam(name = "page_size", defaultValue = "10") int pageSize, |
| | | @PathVariable(name = "workspace_id") String workspaceId |
| | | ) { |
| | | return ResponseResult.success(fileService.getPhotoByJobId(page,pageSize,workspaceId, jobId)); |
| | | return ResponseResult.success(fileService.getPhotoByJobId(page, pageSize, workspaceId, jobId)); |
| | | } |
| | | |
| | | @GetMapping("/{workspace_id}/getJobIds") |
| | | public ResponseResult getJobIds(@PathVariable(name = "workspace_id") String workspaceId, |
| | | @RequestParam(defaultValue = "1") int page, |
| | | @RequestParam(name = "page_size", defaultValue = "10") int pageSize |
| | | ) { |
| | | return ResponseResult.success(fileService.getJobId(page,pageSize,workspaceId)); |
| | | ) { |
| | | return ResponseResult.success(fileService.getJobId(page, pageSize, workspaceId)); |
| | | } |
| | | |
| | | @PutMapping("/examine") |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private static final String BASE_URL = "http://dev.jxpskj.com:9000/cloud-bucket"; |
| | | |
| | | @GetMapping("/download-images") |
| | | public void downloadImages(@RequestParam String jobId, HttpServletResponse response) { |
| | | List<MediaFileEntity> entities = fileService.getMedia(jobId); |
| | | List<String> urls = entities.stream() |
| | | .map(MediaFileEntity::getObjectKey) |
| | | .map(objectKey -> BASE_URL + objectKey) |
| | | .collect(Collectors.toList()); |
| | | |
| | | String outputFolder = "images"; // 存放图片的文件夹 |
| | | new File(outputFolder).mkdirs(); // 创建文件夹 |
| | | |
| | | downloadAndSaveImages(urls, outputFolder); |
| | | zipAndSendFolder(outputFolder, response); |
| | | cleanUp(outputFolder); |
| | | } |
| | | |
| | | } |