Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
chnmuseum-party
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liqin
chnmuseum-party
Commits
e1d716a6
Commit
e1d716a6
authored
Apr 16, 2021
by
liqin
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixed
parent
a4f94d37
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
27 deletions
+31
-27
AssetController.java
...nergy/chnmuseum/party/web/controller/AssetController.java
+31
-27
No files found.
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/AssetController.java
View file @
e1d716a6
package
cn
.
wisenergy
.
chnmuseum
.
party
.
web
.
controller
;
package
cn
.
wisenergy
.
chnmuseum
.
party
.
web
.
controller
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.util.RandomUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
cn.wisenergy.chnmuseum.party.common.dfs.FastDFSUtils
;
import
cn.wisenergy.chnmuseum.party.common.dfs.FastDFSUtils
;
import
cn.wisenergy.chnmuseum.party.common.log.MethodLog
;
import
cn.wisenergy.chnmuseum.party.common.log.MethodLog
;
import
cn.wisenergy.chnmuseum.party.common.log.OperModule
;
import
cn.wisenergy.chnmuseum.party.common.log.OperModule
;
import
cn.wisenergy.chnmuseum.party.common.log.OperType
;
import
cn.wisenergy.chnmuseum.party.common.log.OperType
;
import
cn.wisenergy.chnmuseum.party.common.util.RSAUtils
;
import
cn.wisenergy.chnmuseum.party.common.video.VideoEncryptUtil
;
import
cn.wisenergy.chnmuseum.party.common.video.VideoEncryptUtil
;
import
cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam
;
import
cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam
;
import
cn.wisenergy.chnmuseum.party.model.Asset
;
import
cn.wisenergy.chnmuseum.party.model.Asset
;
import
cn.wisenergy.chnmuseum.party.model.TBoxOperation
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
cn.wisenergy.chnmuseum.party.service.AssetService
;
import
cn.wisenergy.chnmuseum.party.service.AssetService
;
import
cn.wisenergy.chnmuseum.party.service.TBoxOperationService
;
import
cn.wisenergy.chnmuseum.party.service.TBoxOperationService
;
import
cn.wisenergy.chnmuseum.party.web.controller.base.BaseController
;
import
cn.wisenergy.chnmuseum.party.web.controller.base.BaseController
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.github.tobato.fastdfs.domain.fdfs.MetaData
;
import
com.github.tobato.fastdfs.domain.fdfs.MetaData
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -39,7 +33,6 @@ import java.io.ByteArrayOutputStream;
...
@@ -39,7 +33,6 @@ import java.io.ByteArrayOutputStream;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -115,21 +108,16 @@ public class AssetController extends BaseController {
...
@@ -115,21 +108,16 @@ public class AssetController extends BaseController {
response
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
);
response
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
);
response
.
addHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename="
+
URLEncoder
.
encode
(
"video.zip"
,
"UTF-8"
));
response
.
addHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename="
+
URLEncoder
.
encode
(
"video.zip"
,
"UTF-8"
));
final
Map
<
String
,
InputStream
>
map
=
new
LinkedHashMap
<>(
idList
.
size
()
+
1
);
final
Map
<
String
,
InputStream
>
map
=
new
LinkedHashMap
<>(
idList
.
size
());
final
List
<
Asset
>
assetList
=
assetService
.
listByIds
(
idList
);
final
List
<
Asset
>
assetList
=
assetService
.
listByIds
(
idList
);
final
String
cipher
=
RandomUtil
.
randomString
(
BASE_STRING
,
16
);
for
(
final
Asset
asset
:
assetList
)
{
for
(
final
Asset
asset
:
assetList
)
{
final
String
fileUrl
=
asset
.
getFileUrl
();
final
String
fileUrl
Crypto
=
asset
.
getFileUrlCrypto
();
ByteArrayOutputStream
byteOutputStream
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
byteOutputStream
=
new
ByteArrayOutputStream
();
FastDFSUtils
.
downloadFile
(
fileUrl
,
byteOutputStream
);
FastDFSUtils
.
downloadFile
(
fileUrl
Crypto
,
byteOutputStream
);
final
Set
<
MetaData
>
fileMetaData
=
FastDFSUtils
.
getFileMetaData
(
fileUrl
);
final
Set
<
MetaData
>
fileMetaData
=
FastDFSUtils
.
getFileMetaData
(
fileUrl
Crypto
);
String
fileName
=
fileMetaData
.
stream
().
filter
(
x
->
"MD5"
.
equals
(
x
.
getName
())).
map
(
MetaData:
:
getValue
).
findFirst
().
get
()
+
".chnmuseum"
;
String
fileName
=
fileMetaData
.
stream
().
filter
(
x
->
"MD5"
.
equals
(
x
.
getName
())).
map
(
MetaData:
:
getValue
).
findFirst
().
get
()
+
".chnmuseum"
;
map
.
put
(
fileName
,
VideoEncryptUtil
.
encrypt
(
new
ByteArrayInputStream
(
byteOutputStream
.
toByteArray
()),
cipher
));
map
.
put
(
fileName
,
VideoEncryptUtil
.
encrypt
(
new
ByteArrayInputStream
(
byteOutputStream
.
toByteArray
()),
VideoEncryptUtil
.
cipher
));
}
}
final
TUser
user
=
getcurUser
();
final
TBoxOperation
tBoxOperation
=
this
.
tBoxOperationService
.
getOne
(
Wrappers
.<
TBoxOperation
>
lambdaQuery
().
eq
(
TBoxOperation:
:
getOrganId
,
user
.
getOrgId
()));
map
.
put
(
"cipher.txt"
,
IoUtil
.
toStream
(
RSAUtils
.
encrypt
(
cipher
,
tBoxOperation
.
getPublicKey
()),
StandardCharsets
.
UTF_8
));
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
String
[]
paths
=
map
.
keySet
().
toArray
(
new
String
[
0
]);
String
[]
paths
=
map
.
keySet
().
toArray
(
new
String
[
0
]);
InputStream
[]
ins
=
map
.
values
().
toArray
(
new
InputStream
[
0
]);
InputStream
[]
ins
=
map
.
values
().
toArray
(
new
InputStream
[
0
]);
...
@@ -147,20 +135,36 @@ public class AssetController extends BaseController {
...
@@ -147,20 +135,36 @@ public class AssetController extends BaseController {
response
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
);
response
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
);
response
.
addHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename="
+
URLEncoder
.
encode
(
"file.zip"
,
"UTF-8"
));
response
.
addHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename="
+
URLEncoder
.
encode
(
"file.zip"
,
"UTF-8"
));
final
Map
<
String
,
InputStream
>
map
=
new
LinkedHashMap
<>(
idList
.
size
()
+
1
);
final
Map
<
String
,
InputStream
>
map
=
new
LinkedHashMap
<>(
idList
.
size
());
final
List
<
Asset
>
assetList
=
assetService
.
listByIds
(
idList
);
final
List
<
Asset
>
assetList
=
assetService
.
listByIds
(
idList
);
final
String
cipher
=
RandomUtil
.
randomString
(
BASE_STRING
,
16
);
for
(
final
Asset
asset
:
assetList
)
{
for
(
final
Asset
asset
:
assetList
)
{
final
String
fileUrl
=
asset
.
getFileUrl
();
final
String
fileUrl
Crypto
=
asset
.
getFileUrlCrypto
();
ByteArrayOutputStream
byteOutputStream
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
byteOutputStream
=
new
ByteArrayOutputStream
();
FastDFSUtils
.
downloadFile
(
fileUrl
,
byteOutputStream
);
FastDFSUtils
.
downloadFile
(
fileUrl
Crypto
,
byteOutputStream
);
final
Set
<
MetaData
>
fileMetaData
=
FastDFSUtils
.
getFileMetaData
(
fileUrl
);
final
Set
<
MetaData
>
fileMetaData
=
FastDFSUtils
.
getFileMetaData
(
fileUrl
Crypto
);
//
String fileName = fileMetaData.stream().filter(x -> "MD5".equals(x.getName())).map(MetaData::getValue).findFirst().get() + ".chnmuseum";
String
fileName
=
fileMetaData
.
stream
().
filter
(
x
->
"MD5"
.
equals
(
x
.
getName
())).
map
(
MetaData:
:
getValue
).
findFirst
().
get
()
+
".chnmuseum"
;
map
.
put
(
asset
.
getFileName
(),
new
ByteArrayInputStream
(
byteOutputStream
.
toByteArray
()
));
map
.
put
(
fileName
,
VideoEncryptUtil
.
encrypt
(
new
ByteArrayInputStream
(
byteOutputStream
.
toByteArray
()),
VideoEncryptUtil
.
cipher
));
}
}
final
TUser
user
=
getcurUser
();
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
final
TBoxOperation
tBoxOperation
=
this
.
tBoxOperationService
.
getOne
(
Wrappers
.<
TBoxOperation
>
lambdaQuery
().
eq
(
TBoxOperation:
:
getOrganId
,
user
.
getOrgId
()));
String
[]
paths
=
map
.
keySet
().
toArray
(
new
String
[
0
]);
map
.
put
(
"cipher.txt"
,
IoUtil
.
toStream
(
RSAUtils
.
encrypt
(
cipher
,
tBoxOperation
.
getPublicKey
()),
StandardCharsets
.
UTF_8
));
InputStream
[]
ins
=
map
.
values
().
toArray
(
new
InputStream
[
0
]);
ZipUtil
.
zip
(
outputStream
,
paths
,
ins
);
}
@ApiOperation
(
value
=
"视频文件汇出GET"
,
notes
=
"视频文件汇出GET"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"idList"
,
value
=
"视频文件标识ID集合"
,
dataType
=
"String"
,
paramType
=
"query"
)
})
@GetMapping
(
"/downloadCipher"
)
@RequiresAuthentication
@MethodLog
(
operModule
=
OperModule
.
VIDEOREMIT
,
operType
=
OperType
.
VIDEO_EXPORT
)
public
void
downloadCipher
(
@RequestParam
(
"idList"
)
List
<
String
>
idList
,
HttpServletResponse
response
)
throws
IOException
{
response
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
);
response
.
addHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename="
+
URLEncoder
.
encode
(
"file.zip"
,
"UTF-8"
));
final
Map
<
String
,
InputStream
>
map
=
new
LinkedHashMap
<>(
idList
.
size
()
+
1
);
// final TBoxOperation tBoxOperation = this.tBoxOperationService.getOne(Wrappers.<TBoxOperation>lambdaQuery().eq(TBoxOperation::getOrganId, user.getOrgId()));
// map.put("cipher.txt", IoUtil.toStream(RSAUtils.encrypt(VideoEncryptUtil.cipher, tBoxOperation.getPublicKey()), StandardCharsets.UTF_8));
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
String
[]
paths
=
map
.
keySet
().
toArray
(
new
String
[
0
]);
String
[]
paths
=
map
.
keySet
().
toArray
(
new
String
[
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