Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
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
chenjunxiong
guns-vip
Commits
6781d0b3
Commit
6781d0b3
authored
May 04, 2019
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化保存文件大小设置
parent
4e3357a1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletions
+7
-1
src/main/java/cn/stylefeng/guns/modular/system/service/FileInfoService.java
+7
-1
No files found.
src/main/java/cn/stylefeng/guns/modular/system/service/FileInfoService.java
View file @
6781d0b3
...
...
@@ -24,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.math.BigDecimal
;
/**
* <p>
...
...
@@ -136,7 +137,12 @@ public class FileInfoService extends ServiceImpl<FileInfoMapper, FileInfo> {
fileInfo
.
setFileSuffix
(
fileSuffix
);
fileInfo
.
setFilePath
(
fileSavePath
+
finalName
);
fileInfo
.
setFinalName
(
finalName
);
fileInfo
.
setFileSizeKb
(
file
.
getSize
());
//计算文件大小kb
long
kb
=
new
BigDecimal
(
file
.
getSize
())
.
divide
(
BigDecimal
.
valueOf
(
1024
))
.
setScale
(
0
,
BigDecimal
.
ROUND_HALF_UP
).
longValue
();
fileInfo
.
setFileSizeKb
(
kb
);
this
.
save
(
fileInfo
);
}
catch
(
Exception
e
)
{
log
.
error
(
"上传文件错误!"
,
e
);
...
...
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