Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
4c909922
Commit
4c909922
authored
Dec 25, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
取消网关的日志拦截
parent
169b88ad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
base-manager/src/main/java/com/mortals/xhx/base/system/upload/service/impl/UploadServiceImpl.java
...hx/base/system/upload/service/impl/UploadServiceImpl.java
+12
-10
base-manager/src/main/java/com/mortals/xhx/base/system/upload/web/UploadController.java
.../mortals/xhx/base/system/upload/web/UploadController.java
+1
-1
No files found.
base-manager/src/main/java/com/mortals/xhx/base/system/upload/service/impl/UploadServiceImpl.java
View file @
4c909922
...
@@ -2,6 +2,7 @@ package com.mortals.xhx.base.system.upload.service.impl;
...
@@ -2,6 +2,7 @@ package com.mortals.xhx.base.system.upload.service.impl;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.framework.util.StringUtils
;
...
@@ -43,7 +44,6 @@ public class UploadServiceImpl implements UploadService {
...
@@ -43,7 +44,6 @@ public class UploadServiceImpl implements UploadService {
private
String
filePath
;
private
String
filePath
;
@Override
@Override
public
String
saveFileUpload
(
MultipartFile
tempFile
,
String
prePath
,
IUser
user
)
{
public
String
saveFileUpload
(
MultipartFile
tempFile
,
String
prePath
,
IUser
user
)
{
if
(
tempFile
==
null
||
tempFile
.
getSize
()
==
0
)
{
if
(
tempFile
==
null
||
tempFile
.
getSize
()
==
0
)
{
...
@@ -72,12 +72,16 @@ public class UploadServiceImpl implements UploadService {
...
@@ -72,12 +72,16 @@ public class UploadServiceImpl implements UploadService {
File
uploadFile
=
new
File
(
filePathAll
);
File
uploadFile
=
new
File
(
filePathAll
);
try
{
try
{
log
.
info
(
"文件正在储存,filepath:"
+
filePathAll
);
log
.
info
(
"文件正在储存,filepath:"
+
filePathAll
);
tempFile
.
transferTo
(
uploadFile
);
tempFile
.
transferTo
(
uploadFile
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
AppException
(
e
.
getMessage
());
throw
new
AppException
(
e
.
getMessage
());
}
}
boolean
bool
=
StrUtil
.
startWith
(
prePath
,
"/"
);
if
(!
bool
)
{
prePath
=
"/"
+
prePath
;
}
return
(
StringUtils
.
isEmpty
(
prePath
)
?
""
:
prePath
+
"/"
)
+
newName
;
return
(
StringUtils
.
isEmpty
(
prePath
)
?
""
:
prePath
+
"/"
)
+
newName
;
}
}
...
@@ -103,7 +107,7 @@ public class UploadServiceImpl implements UploadService {
...
@@ -103,7 +107,7 @@ public class UploadServiceImpl implements UploadService {
@Override
@Override
public
void
preview
(
String
fileName
,
HttpServletResponse
response
)
{
public
void
preview
(
String
fileName
,
HttpServletResponse
response
)
{
String
filePath
=
this
.
filePath
+
"/file/preview/"
+
fileName
;
String
filePath
=
this
.
filePath
+
"/file/preview/"
+
fileName
;
try
{
try
{
response
.
setContentType
(
MediaType
.
IMAGE_JPEG_VALUE
);
response
.
setContentType
(
MediaType
.
IMAGE_JPEG_VALUE
);
setAttachmentResponseHeader
(
response
,
fileName
);
setAttachmentResponseHeader
(
response
,
fileName
);
...
@@ -121,8 +125,7 @@ public class UploadServiceImpl implements UploadService {
...
@@ -121,8 +125,7 @@ public class UploadServiceImpl implements UploadService {
* @param realFileName 真实文件名
* @param realFileName 真实文件名
* @return
* @return
*/
*/
public
void
setAttachmentResponseHeader
(
HttpServletResponse
response
,
String
realFileName
)
throws
UnsupportedEncodingException
public
void
setAttachmentResponseHeader
(
HttpServletResponse
response
,
String
realFileName
)
throws
UnsupportedEncodingException
{
{
String
percentEncodedFileName
=
percentEncode
(
realFileName
);
String
percentEncodedFileName
=
percentEncode
(
realFileName
);
StringBuilder
contentDispositionValue
=
new
StringBuilder
();
StringBuilder
contentDispositionValue
=
new
StringBuilder
();
...
@@ -142,8 +145,7 @@ public class UploadServiceImpl implements UploadService {
...
@@ -142,8 +145,7 @@ public class UploadServiceImpl implements UploadService {
* @param s 需要百分号编码的字符串
* @param s 需要百分号编码的字符串
* @return 百分号编码后的字符串
* @return 百分号编码后的字符串
*/
*/
public
String
percentEncode
(
String
s
)
throws
UnsupportedEncodingException
public
String
percentEncode
(
String
s
)
throws
UnsupportedEncodingException
{
{
String
encode
=
URLEncoder
.
encode
(
s
,
StandardCharsets
.
UTF_8
.
toString
());
String
encode
=
URLEncoder
.
encode
(
s
,
StandardCharsets
.
UTF_8
.
toString
());
return
encode
.
replaceAll
(
"\\+"
,
"%20"
);
return
encode
.
replaceAll
(
"\\+"
,
"%20"
);
}
}
...
@@ -151,7 +153,7 @@ public class UploadServiceImpl implements UploadService {
...
@@ -151,7 +153,7 @@ public class UploadServiceImpl implements UploadService {
@Override
@Override
public
void
uploadDownload
(
String
fileName
,
HttpServletResponse
response
)
{
public
void
uploadDownload
(
String
fileName
,
HttpServletResponse
response
)
{
String
filePath
=
this
.
filePath
+
fileName
;
String
filePath
=
this
.
filePath
+
fileName
;
try
{
try
{
response
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
);
response
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
);
setAttachmentResponseHeader
(
response
,
fileName
);
setAttachmentResponseHeader
(
response
,
fileName
);
...
@@ -163,7 +165,7 @@ public class UploadServiceImpl implements UploadService {
...
@@ -163,7 +165,7 @@ public class UploadServiceImpl implements UploadService {
@Override
@Override
public
void
deleteFile
(
String
fileName
)
{
public
void
deleteFile
(
String
fileName
)
{
String
filePath
=
this
.
filePath
+
fileName
;
String
filePath
=
this
.
filePath
+
fileName
;
try
{
try
{
FileUtil
.
del
(
filePath
);
FileUtil
.
del
(
filePath
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
base-manager/src/main/java/com/mortals/xhx/base/system/upload/web/UploadController.java
View file @
4c909922
...
@@ -52,7 +52,7 @@ public class UploadController extends BaseController {
...
@@ -52,7 +52,7 @@ public class UploadController extends BaseController {
@RequestMapping
(
value
=
"commonupload"
)
@RequestMapping
(
value
=
"commonupload"
)
public
String
doFileUpload
(
MultipartFile
file
,
@RequestParam
(
value
=
"prePath"
,
defaultValue
=
"file/fileupload"
)
String
prePath
)
{
public
String
doFileUpload
(
MultipartFile
file
,
@RequestParam
(
value
=
"prePath"
,
defaultValue
=
"
/
file/fileupload"
)
String
prePath
)
{
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
String
jsonStr
=
""
;
String
jsonStr
=
""
;
try
{
try
{
...
...
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