Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
ftp_pic
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李辅翼
ftp_pic
Commits
59759779
Commit
59759779
authored
Jul 04, 2019
by
李辅翼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v3
parent
d2d74cda
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
15 deletions
+67
-15
pom.xml
+15
-6
src/main/java/com/hikcreate/controller/PicController.java
+39
-2
src/main/java/com/hikcreate/drv_photo_pic/impl/DrvPhotoImpl.java
+1
-1
src/main/java/com/hikcreate/illegalPic/synchronizationDay.java
+5
-0
src/main/java/com/hikcreate/service/fdfs/service/impl/FileServiceImpl.java
+7
-6
No files found.
pom.xml
View file @
59759779
...
...
@@ -18,6 +18,14 @@
<java.version>
1.8
</java.version>
</properties>
<repositories>
<repository>
<id>
cloudera
</id>
<url>
https://repository.cloudera.com/artifactory/cloudera-repos/
</url>
</repository>
</repositories>
<dependencies>
...
...
@@ -82,6 +90,12 @@
<artifactId>
fastdfs-client
</artifactId>
<version>
1.26.5
</version>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
<version>
2.4
</version>
</dependency>
</dependencies>
<build>
...
...
@@ -92,10 +106,5 @@
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>
cloudera
</id>
<url>
https://repository.cloudera.com/artifactory/cloudera-repos/
</url>
</repository>
</repositories>
</project>
src/main/java/com/hikcreate/controller/PicController.java
View file @
59759779
...
...
@@ -2,6 +2,7 @@ package com.hikcreate.controller;
import
com.alibaba.fastjson.JSONObject
;
import
com.hikcreate.drv_photo_pic.DrvPhoto
;
import
com.hikcreate.service.fdfs.service.FileService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -10,8 +11,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.
IOException
;
import
java.text.SimpleDateFormat
;
import
java.io.
*
;
/**
* @author lifuyi
...
...
@@ -25,6 +26,9 @@ public class PicController {
@Autowired
private
DrvPhoto
drvPhoto
;
@Autowired
private
FileService
fileService
;
@GetMapping
(
"/drvPhotoHis"
)
public
void
getHisDrvPhoto
(
@RequestParam
(
"time"
)
String
time
,
HttpServletResponse
response
){
...
...
@@ -40,4 +44,37 @@ public class PicController {
}
@GetMapping
(
"/testFastDfs"
)
public
void
testFastDfs
(
@RequestParam
(
"url"
)
String
url
,
HttpServletResponse
response
){
try
{
File
file
=
new
File
(
"C:\\Users\\lifuyi5\\Downloads\\2019-05-15"
);
FileInputStream
fis
=
new
FileInputStream
(
file
);
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
(
fis
.
available
());
byte
[]
b
=
new
byte
[
1024
];
int
len
=
-
1
;
while
((
len
=
fis
.
read
(
b
))
!=
-
1
)
{
bos
.
write
(
b
,
0
,
len
);
}
byte
[]
fileByte
=
bos
.
toByteArray
();
String
urlFast
=
fileService
.
uploadFile
(
fileByte
,
"2019-05-15"
);
response
.
setContentType
(
"application/json;charset=UTF-8"
);
response
.
getWriter
().
write
(
urlFast
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@GetMapping
(
"/testUrl"
)
public
void
testUrl
(
@RequestParam
(
"url"
)
String
url
,
HttpServletResponse
response
){
try
{
System
.
out
.
println
(
"dddddddddddddd"
);
response
.
setContentType
(
"application/json;charset=UTF-8"
);
response
.
getWriter
().
write
(
"cjdncvjf"
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
src/main/java/com/hikcreate/drv_photo_pic/impl/DrvPhotoImpl.java
View file @
59759779
...
...
@@ -52,7 +52,6 @@ public class DrvPhotoImpl implements DrvPhoto {
* @param time
* @return
*/
@Override
public
boolean
getHisDrvPhoto
(
String
time
)
{
try
{
endTime
=
time
;
...
...
@@ -112,6 +111,7 @@ public class DrvPhotoImpl implements DrvPhoto {
String
time
=
"2019-07-02 00:00:00"
;
System
.
out
.
println
(
time
.
substring
(
0
,
10
));
System
.
out
.
println
(
s
.
compareTo
(
time
.
substring
(
0
,
10
)));
}
}
src/main/java/com/hikcreate/illegalPic/synchronizationDay.java
View file @
59759779
...
...
@@ -7,6 +7,11 @@ package com.hikcreate.illegalPic;
*/
public
class
synchronizationDay
{
}
...
...
src/main/java/com/hikcreate/service/fdfs/service/impl/FileServiceImpl.java
View file @
59759779
...
...
@@ -10,7 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.annotation.Resource
;
/**
...
...
@@ -19,7 +20,7 @@ import javax.annotation.Resource;
*/
@Service
public
class
FileServiceImpl
implements
FileService
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
FileServiceImpl
.
class
);
@Resource
private
FastDFSClient
fastDFSClient
;
...
...
@@ -32,14 +33,14 @@ public class FileServiceImpl implements FileService {
//将文件上装到fast文件服务器上,成功则返回文件保存的路径
String
path
=
fastDFSClient
.
uploadFile
(
file
,
fileName
);
if
(!
StringUtils
.
hasText
(
path
))
{
// log
.error("Upload Img Error");
logger
.
error
(
"Upload Img Error"
);
}
// log
.info("Upload Img Success. path {}", ("/group" + path.split("group")[1]));
logger
.
info
(
"Upload Img Success. path {}"
,
(
"/group"
+
path
.
split
(
"group"
)[
1
]));
return
"/group"
+
path
.
split
(
"group"
)[
1
];
}
catch
(
Exception
e
)
{
// log
.error("Upload Img Error, msg ={}", e);
// throw new Business
Exception("上传图片失败");
logger
.
error
(
"Upload Img Error, msg ={}"
,
e
);
throw
new
Runtime
Exception
(
"上传图片失败"
);
}
}
...
...
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