Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jz-dmp-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姚本章
jz-dmp-service
Commits
bdaa23b5
Commit
bdaa23b5
authored
Mar 14, 2021
by
mcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
5012b68b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
PictureController.java
...java/com/jz/dmp/modules/controller/PictureController.java
+6
-2
No files found.
src/main/java/com/jz/dmp/modules/controller/PictureController.java
View file @
bdaa23b5
...
@@ -10,6 +10,7 @@ import org.apache.commons.net.ftp.FTPClient;
...
@@ -10,6 +10,7 @@ import org.apache.commons.net.ftp.FTPClient;
import
org.apache.commons.net.ftp.FTPReply
;
import
org.apache.commons.net.ftp.FTPReply
;
import
org.apache.tomcat.util.http.fileupload.IOUtils
;
import
org.apache.tomcat.util.http.fileupload.IOUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -24,7 +25,7 @@ import java.io.InputStream;
...
@@ -24,7 +25,7 @@ import java.io.InputStream;
* @Date: 2021/1/12
* @Date: 2021/1/12
* @Version:
* @Version:
*/
*/
@
Rest
Controller
@Controller
@Api
(
tags
=
"图片处理"
)
@Api
(
tags
=
"图片处理"
)
public
class
PictureController
{
public
class
PictureController
{
...
@@ -80,12 +81,14 @@ public class PictureController {
...
@@ -80,12 +81,14 @@ public class PictureController {
@GetMapping
(
"/dmp/downloadPicture"
)
@GetMapping
(
"/dmp/downloadPicture"
)
@ApiOperation
(
value
=
"图片下载"
)
@ApiOperation
(
value
=
"图片下载"
)
public
JsonResult
downloadPicture
(
@RequestParam
(
name
=
"url"
)
String
url
,
HttpServletResponse
response
)
{
public
JsonResult
downloadPicture
(
@RequestParam
(
name
=
"url"
)
String
url
,
HttpServletResponse
response
)
{
JsonResult
result
=
new
JsonResult
();
JsonResult
result
=
new
JsonResult
();
FTPClient
ftp
=
new
FTPClient
();
FTPClient
ftp
=
new
FTPClient
();
String
catalog
=
url
.
substring
(
url
.
lastIndexOf
(
"="
)+
1
);
String
catalog
=
url
.
substring
(
url
.
lastIndexOf
(
"="
)+
1
);
String
remotePath
=
catalog
.
substring
(
0
,
catalog
.
lastIndexOf
(
"/"
)
+
1
);
String
remotePath
=
catalog
.
substring
(
0
,
catalog
.
lastIndexOf
(
"/"
)
+
1
);
String
furl
=
url
.
substring
(
url
.
lastIndexOf
(
"/"
)
+
1
);
String
furl
=
url
.
substring
(
url
.
lastIndexOf
(
"/"
)
+
1
);
String
suffix
=
catalog
.
substring
(
catalog
.
lastIndexOf
(
"."
));
String
suffix
=
catalog
.
substring
(
catalog
.
lastIndexOf
(
"."
));
try
{
try
{
int
reply
;
int
reply
;
ftp
.
connect
(
ftpUrl
,
port
);
ftp
.
connect
(
ftpUrl
,
port
);
...
@@ -106,7 +109,8 @@ public class PictureController {
...
@@ -106,7 +109,8 @@ public class PictureController {
outputStream
.
write
(
buffer
,
0
,
len
);
outputStream
.
write
(
buffer
,
0
,
len
);
}
}
// byte[] bytes = sos.toByteArray();
// 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
);
IOUtils
.
copy
(
in
,
outputStream
);
in
.
close
();
in
.
close
();
outputStream
.
close
();
outputStream
.
close
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment