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
5609dca6
Commit
5609dca6
authored
Jul 04, 2019
by
牟邦恺
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
add cloudera repo
parent
6bcff9f5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
0 deletions
+75
-0
src/main/java/com/hikcreate/service/fdfs/service/FileService.java
+25
-0
src/main/java/com/hikcreate/service/fdfs/service/impl/FileServiceImpl.java
+50
-0
No files found.
src/main/java/com/hikcreate/service/fdfs/service/FileService.java
0 → 100644
View file @
5609dca6
package
com
.
hikcreate
.
service
.
fdfs
.
service
;
/**
* @author 赵东
* @create 2019/3/22 13:39
*/
public
interface
FileService
{
/**
* 上传文件
* @param file
* @param fileName
* @return
*/
String
uploadFile
(
byte
[]
file
,
String
fileName
);
/**
* 下载文件
*
* @param path 文件路径
* @return 字节数组
*/
byte
[]
downloadFile
(
String
path
);
}
src/main/java/com/hikcreate/service/fdfs/service/impl/FileServiceImpl.java
0 → 100644
View file @
5609dca6
package
com
.
hikcreate
.
service
.
fdfs
.
service
.
impl
;
import
com.github.tobato.fastdfs.domain.fdfs.StorePath
;
import
com.github.tobato.fastdfs.domain.upload.FastImageFile
;
import
com.github.tobato.fastdfs.service.FastFileStorageClient
;
import
com.hikcreate.service.fdfs.FastDFSClient
;
import
com.hikcreate.service.fdfs.service.FileService
;
import
org.apache.commons.io.FilenameUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
/**
* @author 赵东
* @create 2019/3/22 13:45
*/
@Service
public
class
FileServiceImpl
implements
FileService
{
@Resource
private
FastDFSClient
fastDFSClient
;
@Autowired
private
FastFileStorageClient
storageClient
;
@Override
public
String
uploadFile
(
byte
[]
file
,
String
fileName
)
{
try
{
//将文件上装到fast文件服务器上,成功则返回文件保存的路径
String
path
=
fastDFSClient
.
uploadFile
(
file
,
fileName
);
if
(!
StringUtils
.
hasText
(
path
))
{
// log.error("Upload Img Error");
}
// log.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 BusinessException("上传图片失败");
}
}
@Override
public
byte
[]
downloadFile
(
String
path
)
{
return
fastDFSClient
.
download
(
path
);
}
}
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