Commit bdaa23b5 authored by mcb's avatar mcb

commit

parent 5012b68b
......@@ -10,6 +10,7 @@ import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
......@@ -24,7 +25,7 @@ import java.io.InputStream;
* @Date: 2021/1/12
* @Version:
*/
@RestController
@Controller
@Api(tags = "图片处理")
public class PictureController {
......@@ -80,12 +81,14 @@ public class PictureController {
@GetMapping("/dmp/downloadPicture")
@ApiOperation(value = "图片下载")
public JsonResult downloadPicture(@RequestParam(name = "url") String url, HttpServletResponse response) {
JsonResult result = new JsonResult();
FTPClient ftp = new FTPClient();
String catalog = url.substring(url.lastIndexOf("=")+ 1);
String remotePath = catalog.substring(0, catalog.lastIndexOf("/") + 1);
String furl = url.substring(url.lastIndexOf("/") +1);
String suffix = catalog.substring(catalog.lastIndexOf("."));
try {
int reply;
ftp.connect(ftpUrl, port);
......@@ -106,7 +109,8 @@ public class PictureController {
outputStream.write(buffer, 0, len);
}
// byte[] bytes = sos.toByteArray();
response.setHeader("Content-Disposition", "attachment;filename="+suffix);
response.setContentType("image/jpeg;charset=utf-8");
//response.setHeader("Content-Disposition", "attachment;filename="+suffix);
IOUtils.copy(in, outputStream);
in.close();
outputStream.close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment