Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoban3.0
haoban-manage3.0
Commits
0fc02905
Commit
0fc02905
authored
Jan 21, 2022
by
fudahua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:上传日志
parent
252dc878
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
13 deletions
+21
-13
UploadController.java
...om/gic/haoban/manage/web/controller/UploadController.java
+21
-13
No files found.
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/UploadController.java
View file @
0fc02905
...
...
@@ -8,6 +8,8 @@ import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import
com.gic.qcloud.BucketNameEnum
;
import
com.gic.qcloud.FileUploadUtil
;
import
org.apache.commons.io.FileUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
...
@@ -22,7 +24,7 @@ import java.util.Set;
@RestController
public
class
UploadController
extends
WebBaseController
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
UploadController
.
class
);
private
static
Set
<
String
>
FILE_TYPE
=
new
HashSet
<>(
);
static
{
for
(
BucketNameEnum
value:
BucketNameEnum
.
values
()){
...
...
@@ -56,20 +58,26 @@ public class UploadController extends WebBaseController{
String
key
=
"haoban/"
+
dayFilePath
+
"/"
+
name
;
fileType
=
FILE_TYPE
.
contains
(
fileType
)?
fileType:
BucketNameEnum
.
OTHER_90000
.
getName
();
String
url
=
FileUploadUtil
.
simpleUploadFileFromLocal
(
templateFile
,
key
,
fileType
);
try
{
String
url
=
FileUploadUtil
.
simpleUploadFileFromLocal
(
templateFile
,
key
,
fileType
);
if
(
templateFile
!=
null
)
{
templateFile
.
delete
();
}
if
(
templateFile
!=
null
)
{
templateFile
.
delete
();
}
JSONObject
res
=
new
JSONObject
(
);
res
.
put
(
"name"
,
name
);
res
.
put
(
"mediaName"
,
mediaName
);
res
.
put
(
"ext"
,
suffix
);
res
.
put
(
"size"
,
len
);
res
.
put
(
"key"
,
key
);
res
.
put
(
"url"
,
"https://"
+
url
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
res
);
JSONObject
res
=
new
JSONObject
();
res
.
put
(
"name"
,
name
);
res
.
put
(
"mediaName"
,
mediaName
);
res
.
put
(
"ext"
,
suffix
);
res
.
put
(
"size"
,
len
);
res
.
put
(
"key"
,
key
);
res
.
put
(
"url"
,
"https://"
+
url
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
res
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
info
(
"异常:{}"
,
e
);
return
resultResponse
(
HaoBanErrCode
.
ERR_0
);
}
}
}
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