Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
f7d943cd
Commit
f7d943cd
authored
Jun 19, 2018
by
neo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DEV] 文] file upload bug fixed
parent
abd6fffd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
FileUploadAdapter.java
.../pwc/taxtech/atms/vat/service/impl/FileUploadAdapter.java
+4
-4
No files found.
atms-api/src/main/java/pwc/taxtech/atms/vat/service/impl/FileUploadAdapter.java
View file @
f7d943cd
...
@@ -58,7 +58,7 @@ public class FileUploadAdapter {
...
@@ -58,7 +58,7 @@ public class FileUploadAdapter {
if
(
paramBean
.
totalSize
>
Long
.
valueOf
(
maxFileSize
))
if
(
paramBean
.
totalSize
>
Long
.
valueOf
(
maxFileSize
))
return
ResponseEntity
.
badRequest
().
body
(
"InvalidFileSize"
);
return
ResponseEntity
.
badRequest
().
body
(
"InvalidFileSize"
);
String
baseFolder
=
prepareFolder
();
String
baseFolder
=
prepareFolder
();
if
(
!
Utils
.
isEmpty
(
baseFolder
))
return
ResponseEntity
.
badRequest
().
body
(
"PrepareFolderError"
);
if
(
Utils
.
isEmpty
(
baseFolder
))
return
ResponseEntity
.
badRequest
().
body
(
"PrepareFolderError"
);
String
tempPath
=
String
.
format
(
"%s"
+
File
.
separator
+
"%s"
,
baseFolder
,
paramBean
.
tempFileName
);
String
tempPath
=
String
.
format
(
"%s"
+
File
.
separator
+
"%s"
,
baseFolder
,
paramBean
.
tempFileName
);
String
completePath
=
String
.
format
(
"%s"
+
File
.
separator
+
"%s"
,
baseFolder
,
paramBean
.
tempFileName
);
String
completePath
=
String
.
format
(
"%s"
+
File
.
separator
+
"%s"
,
baseFolder
,
paramBean
.
tempFileName
);
...
@@ -74,11 +74,11 @@ public class FileUploadAdapter {
...
@@ -74,11 +74,11 @@ public class FileUploadAdapter {
}
}
try
(
FileOutputStream
fos
=
new
FileOutputStream
(
new
File
(
tempPath
));
try
(
FileOutputStream
fos
=
new
FileOutputStream
(
new
File
(
tempPath
));
InputStream
inputStream
=
request
.
getFile
(
FILE_NAME
).
getInputStream
();)
{
InputStream
inputStream
=
request
.
getFile
Map
().
get
(
"file"
).
getInputStream
();)
{
byte
[]
buffer
=
new
byte
[
4096
];
byte
[]
buffer
=
new
byte
[
4096
];
int
bytesRead
;
int
bytesRead
;
while
((
bytesRead
=
inputStream
.
read
(
buffer
,
0
,
buffer
.
length
))
!=
0
)
{
while
((
bytesRead
=
inputStream
.
read
(
buffer
,
0
,
buffer
.
length
))
>
0
)
{
fos
.
write
(
buffer
,
0
,
bytesRead
);
fos
.
write
(
buffer
,
0
,
bytesRead
);
}
}
...
@@ -127,7 +127,7 @@ public class FileUploadAdapter {
...
@@ -127,7 +127,7 @@ public class FileUploadAdapter {
}
}
private
String
prepareFolder
()
{
private
String
prepareFolder
()
{
String
uploadFolder
=
String
.
format
(
"~
/
%s"
,
UPLOAD_FOLDER_NAME
);
String
uploadFolder
=
String
.
format
(
"~
"
+
File
.
separator
+
"
%s"
,
UPLOAD_FOLDER_NAME
);
if
(
containsSubFolder
)
{
if
(
containsSubFolder
)
{
Calendar
now
=
Calendar
.
getInstance
();
Calendar
now
=
Calendar
.
getInstance
();
now
.
setTime
(
new
Date
());
now
.
setTime
(
new
Date
());
...
...
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