Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-process-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 67114fea
authored
Sep 26, 2023
by
zhouhaibao
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]引入导出工具类
1 parent
b37ea21a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
174 additions
and
0 deletions
platform-process/src/main/java/cn/com/glsx/process/util/FileUploadServerData.java
platform-process/src/main/java/cn/com/glsx/process/util/FileUploadUtil.java
platform-process/src/main/java/cn/com/glsx/process/util/FileUploadServerData.java
0 → 100644
View file @
67114fe
package
cn
.
com
.
glsx
.
process
.
util
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.Serializable
;
@SuppressWarnings
(
"serial"
)
public
class
FileUploadServerData
implements
Serializable
{
public
static
final
int
UPLOAD_SUCCSSS
=
0
;
// "上传文件成功!",
public
static
final
int
UPLOAD_FAILURE
=
1
;
// "上传文件失败!"),
//private static final int UPLOAD_TYPE_ERROR = 2; // "上传文件类型错误!"),
//private static final int UPLOAD_OVERSIZE = 3; // "上传文件过大!"),
//private static final int UPLOAD_ZEROSIZE = 4; // "上传文件为空!"),
//private static final int UPLOAD_NOTFOUND = 5; // "上传文件路径错误!")
private
Integer
status
=
0
;
private
String
message
=
""
;
private
String
url
=
""
;
private
String
systemSign
;
private
String
filePath
;
private
String
param1
;
private
String
param2
;
private
String
param3
;
private
String
secureUrl
;
public
Integer
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
String
getSystemSign
()
{
return
systemSign
;
}
public
void
setSystemSign
(
String
systemSign
)
{
this
.
systemSign
=
systemSign
;
}
public
String
getFilePath
()
{
return
filePath
;
}
public
void
setFilePath
(
String
filePath
)
{
this
.
filePath
=
filePath
;
}
public
String
getParam1
()
{
return
param1
;
}
public
void
setParam1
(
String
param1
)
{
this
.
param1
=
param1
;
}
public
String
getParam2
()
{
return
param2
;
}
public
void
setParam2
(
String
param2
)
{
this
.
param2
=
param2
;
}
public
String
getParam3
()
{
return
param3
;
}
public
void
setParam3
(
String
param3
)
{
this
.
param3
=
param3
;
}
public
String
getSecureUrl
()
{
return
secureUrl
;
}
public
void
setSecureUrl
(
String
secureUrl
)
{
this
.
secureUrl
=
secureUrl
;
}
@Override
public
String
toString
()
{
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"{"
);
sb
.
append
(
"status:"
+
this
.
status
+
","
);
sb
.
append
(
"message:'"
+
this
.
message
+
"',"
);
sb
.
append
(
"url:'"
+
this
.
url
+
"',"
);
sb
.
append
(
"systemSign:'"
+
this
.
systemSign
+
"',"
);
sb
.
append
(
"filePath:'"
+
this
.
filePath
+
"',"
);
sb
.
append
(
"param1:'"
+
this
.
param1
+
"',"
);
sb
.
append
(
"param2:'"
+
this
.
param2
+
"',"
);
sb
.
append
(
"param3:'"
+
this
.
param3
+
"'"
);
sb
.
append
(
"secureUrl:'"
+
this
.
secureUrl
+
"'"
);
sb
.
append
(
"}"
);
return
sb
.
toString
();
}
public
FileUploadServerData
()
{
}
public
FileUploadServerData
(
HttpServletRequest
request
)
{
this
.
systemSign
=
request
.
getParameter
(
"systemSign"
);
this
.
filePath
=
request
.
getParameter
(
"filePath"
);
this
.
param1
=
request
.
getParameter
(
"param1"
);
this
.
param2
=
request
.
getParameter
(
"param2"
);
this
.
param3
=
request
.
getParameter
(
"param3"
);
}
}
platform-process/src/main/java/cn/com/glsx/process/util/FileUploadUtil.java
0 → 100644
View file @
67114fe
package
cn
.
com
.
glsx
.
process
.
util
;
import
org.apache.commons.codec.binary.Base64
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.List
;
/**
* @author wangxw
* @version 1.0.0
* @ClassName FileUploadUtil.java
* @description: 文件上传操作类
* @createTime 2019年11月24日 14:29:00
*/
public
class
FileUploadUtil
{
public
static
final
String
FILE_UPLOAD_URL
=
"http://gfs.glsx.com.cn/file/upstring"
;
private
static
final
String
FILE_ZIP_URL
=
"http://gfs.glsx.com.cn/file/zip"
;
private
static
final
String
FILE_UPLOAD_TEST_URL
=
"http://gfs.test.glsx.com.cn/file/upstring"
;
// blib 供应链
// biz 业务
private
static
final
String
dir_content
=
"biz"
;
/**
* 将文件上传至文件服务器
* @param uploadData
* @param fileType
* @return
*/
public
static
FileUploadServerData
uploadToFileSystem
(
String
fileName
,
byte
[]
uploadData
,
String
fileType
)
{
RestTemplate
restTemplate
=
new
RestTemplate
();
MultiValueMap
<
String
,
String
>
form
=
new
LinkedMultiValueMap
<
String
,
String
>();
form
.
add
(
"systemSign"
,
dir_content
);
form
.
add
(
"param1"
,
fileName
);
form
.
add
(
"files"
,
fileType
+
"@"
+
Base64
.
encodeBase64String
(
uploadData
));
// return restTemplate.postForObject(FILE_UPLOAD_URL, form, FileUploadServerData.class);
return
restTemplate
.
postForObject
(
FILE_UPLOAD_URL
,
form
,
FileUploadServerData
.
class
);
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment