Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
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
徐少华
midjourney-proxy
Commits
aabd384a
Commit
aabd384a
authored
Sep 12, 2018
by
songxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
配置中心切换到GIT
parent
773e7cdc
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
24 deletions
+51
-24
bootstrap.yml
pcloud-common-config/src/main/resources.prod/bootstrap.yml
+1
-1
bootstrap.yml
pcloud-common-config/src/main/resources.uat/bootstrap.yml
+1
-1
OssUtils.java
...rc/main/java/com/pcloud/common/utils/aliyun/OssUtils.java
+0
-0
CompressUtils.java
.../main/java/com/pcloud/common/utils/zip/CompressUtils.java
+49
-22
No files found.
pcloud-common-config/src/main/resources.prod/bootstrap.yml
View file @
aabd384a
...
...
@@ -5,7 +5,7 @@ spring:
enabled
:
true
service-id
:
cloud-config
profile
:
default
label
:
prod
label
:
master
loadbalancer
:
retry
:
enabled
:
true
...
...
pcloud-common-config/src/main/resources.uat/bootstrap.yml
View file @
aabd384a
...
...
@@ -5,7 +5,7 @@ spring:
enabled
:
true
service-id
:
cloud-config
profile
:
default
label
:
uat
label
:
master
loadbalancer
:
retry
:
enabled
:
true
...
...
pcloud-common/src/main/java/com/pcloud/common/utils/aliyun/OssUtils.java
View file @
aabd384a
pcloud-common/src/main/java/com/pcloud/common/utils/zip/CompressUtils.java
View file @
aabd384a
...
...
@@ -64,7 +64,8 @@ public class CompressUtils {
if
(
ListUtils
.
isEmpty
(
fileUrlList
))
{
return
null
;
}
String
tempZipName
=
FileUtils
.
formatName
(
zipName
)
+
"_"
+
UUIDUitl
.
generateString
(
12
);
zipName
=
FileUtils
.
formatName
(
zipName
);
String
tempZipName
=
zipName
+
"_"
+
UUIDUitl
.
generateString
(
12
);
// 检查临时文件夹是否存在,不存在就创建
String
fileFolderPath
=
FILE_LOCAL_PATH
+
tempZipName
;
FileUtils
.
isDir
(
fileFolderPath
);
...
...
@@ -95,32 +96,33 @@ public class CompressUtils {
return
uploadResultInfo
;
}
/**
* 压缩文件(带目录)
*
* @param catalogFiles
key : 目录名
*
String[0]=文件名称, String[1]=文件地址
* @param catalogFiles
*
key : 目录名 String[0]=文件名称, String[1]=文件地址
* @param zipName
* @return
* @throws BizException
*/
public
static
UploadResultInfo
zipByCatalog
(
Map
<
String
,
List
<
String
[]>>
catalogFiles
,
String
zipName
)
throws
BizException
{
public
static
UploadResultInfo
zipByCatalog
(
Map
<
String
,
List
<
String
[]>>
catalogFiles
,
String
zipName
)
throws
BizException
{
LOGGER
.
info
(
"【压缩】压缩文件.<START>"
);
if
(
MapUtils
.
isEmpty
(
catalogFiles
))
{
return
null
;
}
String
tempZipName
=
FileUtils
.
formatName
(
zipName
)
+
"_"
+
UUIDUitl
.
generateString
(
12
);
zipName
=
FileUtils
.
formatName
(
zipName
);
String
tempZipName
=
zipName
+
"_"
+
UUIDUitl
.
generateString
(
12
);
String
parentPath
=
FILE_LOCAL_PATH
+
tempZipName
;
FileUtils
.
isDir
(
parentPath
);
for
(
String
catalog
:
catalogFiles
.
keySet
())
{
for
(
String
catalog
:
catalogFiles
.
keySet
())
{
String
downloadPath
;
// 检查临时文件夹是否存在,不存在就创建
if
(!
StringUtil
.
isEmpty
(
catalog
))
{
String
catalogFolderPath
=
parentPath
+
"/"
+
catalog
;
if
(!
StringUtil
.
isEmpty
(
catalog
))
{
String
catalogFolderPath
=
parentPath
+
"/"
+
catalog
;
FileUtils
.
isDir
(
catalogFolderPath
);
downloadPath
=
catalogFolderPath
;
}
else
{
}
else
{
downloadPath
=
parentPath
;
}
List
<
String
[]>
fileUrlList
=
catalogFiles
.
get
(
catalog
);
...
...
@@ -129,8 +131,7 @@ public class CompressUtils {
for
(
String
[]
files
:
fileUrlList
)
{
String
fileType
=
FileUtils
.
getFileType
(
files
[
1
]);
String
fileName
=
FileUtils
.
formatName
(
files
[
0
]);
String
downloadLocalPath
=
downloadPath
+
"/"
+
fileName
+
"_"
+
idx
+
"."
+
fileType
;
String
downloadLocalPath
=
downloadPath
+
"/"
+
fileName
+
"_"
+
idx
+
"."
+
fileType
;
FileUtils
.
downloadFileFromUrl
(
files
[
1
],
downloadLocalPath
);
idx
++;
}
...
...
@@ -153,7 +154,6 @@ public class CompressUtils {
return
uploadResultInfo
;
}
/**
* @Desc ZIP文件解压
* @param zipPath
...
...
@@ -250,8 +250,8 @@ public class CompressUtils {
File
inputFile
=
new
File
(
inputFilename
);
ZipOutputStream
out
=
new
ZipOutputStream
(
new
FileOutputStream
(
zipFilename
));
try
{
compress
byType
(
inputFile
,
out
,
""
);
// zip(inputFile, out, "");
compress
(
inputFile
,
out
);
// zip(inputFile, out, "");
}
catch
(
Exception
e
)
{
throw
e
;
}
finally
{
...
...
@@ -305,21 +305,29 @@ public class CompressUtils {
* @param zos
* @param baseDir
*/
private
static
void
compressbyType
(
File
src
,
ZipOutputStream
zos
,
String
baseDir
)
{
private
static
void
compress
(
File
src
,
ZipOutputStream
zos
)
{
compressbyType
(
src
,
zos
,
""
,
true
);
}
/**
* 按照原路径的类型就行压缩。文件路径直接把文件压缩,
*
* @param src
* @param zos
* @param baseDir
*/
private
static
void
compressbyType
(
File
src
,
ZipOutputStream
zos
,
String
baseDir
,
boolean
isFirst
)
{
if
(!
src
.
exists
())
return
;
// 判断文件是否是文件,如果是文件调用compressFile方法,如果是路径,则调用compressDir方法;
if
(
src
.
isFile
())
{
// src是文件,调用此方法
compressFile
(
src
,
zos
,
baseDir
);
}
else
if
(
src
.
isDirectory
())
{
// src是文件夹,调用此方法
compressDir
(
src
,
zos
,
baseDir
);
compressDir
(
src
,
zos
,
baseDir
,
isFirst
);
}
}
/**
...
...
@@ -345,11 +353,11 @@ public class CompressUtils {
/**
* 压缩文件夹
*/
private
static
void
compressDir
(
File
dir
,
ZipOutputStream
zos
,
String
baseDir
)
{
private
static
void
compressDir
(
File
dir
,
ZipOutputStream
zos
,
String
baseDir
,
boolean
isFirst
)
{
if
(!
dir
.
exists
())
return
;
File
[]
files
=
dir
.
listFiles
();
if
(
files
.
length
==
0
)
{
if
(
files
.
length
==
0
&&
!
StringUtil
.
isEmpty
(
baseDir
))
{
try
{
zos
.
putNextEntry
(
new
ZipEntry
(
baseDir
+
dir
.
getName
()
+
File
.
separator
));
}
catch
(
IOException
e
)
{
...
...
@@ -357,8 +365,27 @@ public class CompressUtils {
}
}
for
(
File
file
:
files
)
{
compressbyType
(
file
,
zos
,
baseDir
+
dir
.
getName
()+
File
.
separator
);
if
(
isFirst
)
{
compressbyType
(
file
,
zos
,
baseDir
,
false
);
}
else
{
compressbyType
(
file
,
zos
,
baseDir
+
dir
.
getName
()
+
File
.
separator
,
false
);
}
}
}
/**
* @Desc 压缩zip文件 @param inputFilename 待压缩的文件名称或文件夹路径名称 @param zipFilename
* 压缩后的文件完整的路径名称 @throws
*/
public
static
void
zip
(
String
inputFilename
,
ZipOutputStream
out
)
throws
IOException
{
File
inputFile
=
new
File
(
inputFilename
);
try
{
compress
(
inputFile
,
out
);
// zip(inputFile, out, "");
}
catch
(
Exception
e
)
{
throw
e
;
}
finally
{
out
.
close
();
}
}
}
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