Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
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
8timerv2
8timerapiv200
Commits
d64e9ab8
Commit
d64e9ab8
authored
Apr 27, 2021
by
Your Name
Committed by
chenzg
Jul 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新讯息列表文件不能下载问题
parent
9bc1ac79
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
src/main/java/cn/timer/api/controller/oss/OSSController.java
+17
-2
src/main/java/cn/timer/api/service/OSSService.java
+6
-0
No files found.
src/main/java/cn/timer/api/controller/oss/OSSController.java
View file @
d64e9ab8
...
...
@@ -31,7 +31,7 @@ public class OSSController {
private
OSSService
ossService
;
/**
* 上传
普通文
件
* 上传
附
件
*
* @param userBean
* @param moudle
...
...
@@ -39,11 +39,26 @@ public class OSSController {
@PostMapping
(
value
=
"/upload"
)
@ApiOperation
(
value
=
"上传普通文件"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ResponseBody
public
Result
<
String
>
upload
(
@CurrentUser
UserBean
userBean
,
@RequestParam
(
required
=
false
)
String
moudle
,
@
RequestParam
(
"filenam
e"
)
MultipartFile
file
)
throws
Exception
{
public
Result
<
String
>
upload
(
@CurrentUser
UserBean
userBean
,
@RequestParam
(
required
=
false
)
String
moudle
,
@
Param
(
"fil
e"
)
MultipartFile
file
)
throws
Exception
{
Result
<
String
>
data
=
ossService
.
upload
(
userBean
.
getOrgCode
(),
moudle
,
file
);
return
data
;
}
/**
* 上传审批文件
*
* @param userBean
* @param moudle
*/
@PostMapping
(
value
=
"/approveUpload"
)
@ApiOperation
(
value
=
"上传普通文件"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ResponseBody
public
Result
<
String
>
approveUpload
(
@CurrentUser
UserBean
userBean
,
@RequestParam
(
required
=
false
)
String
moudle
,
@RequestParam
(
"filename"
)
MultipartFile
file
)
throws
Exception
{
Result
<
String
>
data
=
ossService
.
upload
(
userBean
.
getOrgCode
(),
moudle
,
file
);
return
data
;
}
/**
* 批量上传普通文件
...
...
src/main/java/cn/timer/api/service/OSSService.java
View file @
d64e9ab8
...
...
@@ -13,6 +13,7 @@ import java.io.File;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.locks.ReentrantLock
;
/**
* 上传文件的实现层
...
...
@@ -23,6 +24,8 @@ public class OSSService implements OSSServiceImpl {
@Autowired
private
OSSUtil
oss
;
private
static
ReentrantLock
lock
=
new
ReentrantLock
();
/**
*
* @param orgCode
...
...
@@ -32,6 +35,7 @@ public class OSSService implements OSSServiceImpl {
*/
@Override
public
Result
<
String
>
upload
(
int
orgCode
,
String
moudle
,
MultipartFile
file
)
{
lock
.
lock
();
String
url
=
null
;
String
randomNickname
=
RandomNum
.
getRandomNickname
();
File
filePath
=
filePathUpload
(
orgCode
,
moudle
,
randomNickname
,
file
.
getOriginalFilename
());
...
...
@@ -41,6 +45,7 @@ public class OSSService implements OSSServiceImpl {
i
++;
}
if
(
file
==
null
||
file
.
getSize
()
<=
0
)
{
lock
.
unlock
();
return
ResultUtil
.
error
(
"上传的文件为空,请重新选择!"
);
}
else
{
try
{
...
...
@@ -48,6 +53,7 @@ public class OSSService implements OSSServiceImpl {
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
lock
.
unlock
();
return
ResultUtil
.
data
(
url
,
"上传成功!"
);
}
}
...
...
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