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
44b1f4bd
Commit
44b1f4bd
authored
Dec 03, 2018
by
songxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
图片转webp格式
parent
fd523fce
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
43 deletions
+27
-43
FileUtils.java
...mmon/src/main/java/com/pcloud/common/utils/FileUtils.java
+10
-5
OssUtils.java
...rc/main/java/com/pcloud/common/utils/aliyun/OssUtils.java
+17
-38
No files found.
pcloud-common/src/main/java/com/pcloud/common/utils/FileUtils.java
View file @
44b1f4bd
...
@@ -109,7 +109,7 @@ public class FileUtils {
...
@@ -109,7 +109,7 @@ public class FileUtils {
/**
/**
* 图片文件格式
* 图片文件格式
*/
*/
public
static
final
String
[]
IMAGE_GATHER
=
{
"BMP"
,
"JPG"
,
"GIF"
,
"PNG"
,
"PCX"
,
"TIF"
,
"JPEG"
,
"SVG"
};
public
static
final
String
[]
IMAGE_GATHER
=
{
"BMP"
,
"JPG"
,
"GIF"
,
"PNG"
,
"PCX"
,
"TIF"
,
"JPEG"
,
"SVG"
,
"WEBP"
};
/**
/**
* 音頻文件格式 【"LRC" 为歌词字幕(这里作为音頻文件上传)】
* 音頻文件格式 【"LRC" 为歌词字幕(这里作为音頻文件上传)】
...
@@ -864,6 +864,7 @@ public class FileUtils {
...
@@ -864,6 +864,7 @@ public class FileUtils {
lines
.
forEach
(
line
->
{
lines
.
forEach
(
line
->
{
result
.
append
(
line
+
System
.
lineSeparator
());
result
.
append
(
line
+
System
.
lineSeparator
());
});
});
lines
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"【文件工具】读取文件内容8.<ERROR>:"
+
e
.
getMessage
(),
e
);
LOGGER
.
error
(
"【文件工具】读取文件内容8.<ERROR>:"
+
e
.
getMessage
(),
e
);
}
finally
{
}
finally
{
...
@@ -877,7 +878,8 @@ public class FileUtils {
...
@@ -877,7 +878,8 @@ public class FileUtils {
* 文件剪切,网络路径、按文件大小的百分比
* 文件剪切,网络路径、按文件大小的百分比
*
*
* @param url
* @param url
* @param percent 1~100的整数
* @param percent
* 1~100的整数
* @return 返回剪切后上传后的文件路径
* @return 返回剪切后上传后的文件路径
* @throws BizException
* @throws BizException
*/
*/
...
@@ -908,7 +910,8 @@ public class FileUtils {
...
@@ -908,7 +910,8 @@ public class FileUtils {
* 文件剪切,本地路径、按百分比
* 文件剪切,本地路径、按百分比
*
*
* @param inputFile
* @param inputFile
* @param cutPercent 1~100的整数
* @param cutPercent
* 1~100的整数
* @return 返回本地路径地址
* @return 返回本地路径地址
* @throws BizException
* @throws BizException
*/
*/
...
@@ -926,8 +929,10 @@ public class FileUtils {
...
@@ -926,8 +929,10 @@ public class FileUtils {
/**
/**
* 文件剪切
* 文件剪切
*
*
* @param inputFile 待剪切的文件
* @param inputFile
* @param cutLength 剪切长度(Byte)
* 待剪切的文件
* @param cutLength
* 剪切长度(Byte)
*/
*/
public
static
String
clipByLength
(
File
inputFile
,
long
cutLength
)
throws
BizException
{
public
static
String
clipByLength
(
File
inputFile
,
long
cutLength
)
throws
BizException
{
LOGGER
.
info
(
"【文件API】文件剪切.<START>.[cutLength]="
+
cutLength
);
LOGGER
.
info
(
"【文件API】文件剪切.<START>.[cutLength]="
+
cutLength
);
...
...
pcloud-common/src/main/java/com/pcloud/common/utils/aliyun/OssUtils.java
View file @
44b1f4bd
...
@@ -151,6 +151,23 @@ public class OssUtils {
...
@@ -151,6 +151,23 @@ public class OssUtils {
}
}
/**
/**
* 父子文件上传,子文件全路径和父文件相同,文件后缀类型自定义
*
* @param filePath
* 子文件本地路径
* @param parentFileUrl
* 仅限OSS的全路径,其他本地文件路径均不支持
* @return
* @throws FileException
*/
public
static
UploadResultInfo
uploadLocalFile4Child
(
String
filePath
,
String
parentFileUrl
)
throws
FileException
{
String
fileType
=
FileUtils
.
getFileType
(
filePath
);
String
outObjectKey
=
splitObjectKey
(
parentFileUrl
)
+
"."
+
fileType
;
uploadPointFile2OSS
(
filePath
,
AliyunConstant
.
FILE_BUCKET
,
outObjectKey
);
return
getResultInfo
(
outObjectKey
,
new
File
(
filePath
).
length
(),
null
,
AliyunConstant
.
FILE_BUCKET
);
}
/**
* byte[]数组文件流上传 ,isFlag=true,表示上传成功
* byte[]数组文件流上传 ,isFlag=true,表示上传成功
*
*
* @param buff
* @param buff
...
@@ -747,36 +764,6 @@ public class OssUtils {
...
@@ -747,36 +764,6 @@ public class OssUtils {
return
resultFileUrl
;
return
resultFileUrl
;
}
}
public
static
String
submitClipJobFixBug
(
String
fileName
,
String
fileUrl
,
String
seek
,
String
duration
)
throws
FileException
{
LOGGER
.
info
(
"【aliOSS】提交音视频剪切作业(fixBug).<START>.[fileUrl]="
+
fileUrl
+
",[seek]="
+
seek
+
",[duration]="
+
duration
);
if
(
StringUtil
.
isEmpty
(
duration
))
{
return
null
;
}
String
fileType
=
FileUtils
.
getFileType
(
fileUrl
);
String
gatherName
=
FileUtils
.
getGatherName
(
fileType
);
if
(!(
FileUtils
.
VIDEO
.
equals
(
gatherName
)
||
FileUtils
.
AUDIO
.
equals
(
gatherName
)))
{
return
null
;
}
String
resultFileUrl
=
""
;
String
outFileType
=
FileUtils
.
VIDEO
.
equals
(
gatherName
)
?
"mp4"
:
"mp3"
;
if
(
StringTools
.
contains
(
fileUrl
,
AliyunConstant
.
OSS_CDN_URLS
))
{
String
inObjectKey
=
splitObjectKey
(
fileUrl
);
String
inBucketName
=
fileUrlExist001
(
fileUrl
)
?
AliyunConstant
.
INPUT_BUCKET
:
AliyunConstant
.
getBucketName
(
fileUrl
);
OSSFileDO
ossFileDO
=
new
OSSFileDO
(
AliyunConstant
.
getOssRegion
(
inBucketName
),
inBucketName
,
inObjectKey
);
String
outObjectKey
=
getOutObjectKeyFixBug
(
AliyunEnum
.
CUT
.
value
,
fileName
,
outFileType
);
resultFileUrl
=
clipJob
(
ossFileDO
,
outObjectKey
,
seek
,
duration
);
}
else
{
String
inObjectKey
=
getInObjectKey
(
AliyunEnum
.
CUT
.
value
,
fileName
,
fileType
);
OSSFileDO
ossFileDO
=
uploadPointFile2OSS
(
fileUrl
,
AliyunConstant
.
FILE_BUCKET
,
inObjectKey
);
String
outObjectKey
=
getOutObjectKey
(
AliyunEnum
.
CUT
.
value
,
fileName
,
outFileType
);
resultFileUrl
=
clipJob
(
ossFileDO
,
outObjectKey
,
seek
,
duration
);
}
LOGGER
.
info
(
"【aliOSS】提交音视频剪切作业.<END>.[resultFileUrl]="
+
resultFileUrl
);
return
resultFileUrl
;
}
/**
/**
* 提交视频剪切作业
* 提交视频剪切作业
*
*
...
@@ -1279,14 +1266,6 @@ public class OssUtils {
...
@@ -1279,14 +1266,6 @@ public class OssUtils {
.
append
(
"/"
).
append
(
fileName
).
append
(
"."
).
append
(
fileType
).
toString
();
.
append
(
"/"
).
append
(
fileName
).
append
(
"."
).
append
(
fileType
).
toString
();
}
}
private
static
String
getOutObjectKeyFixBug
(
String
uploadType
,
String
fileName
,
String
fileType
)
{
fileName
=
StringUtil
.
isEmpty
(
fileName
)
?
UUIDUitl
.
taskName
()
:
FileUtils
.
formatName
(
fileName
);
String
gatherName
=
FileUtils
.
getGatherName
(
fileType
);
gatherName
=
StringUtil
.
isEmpty
(
gatherName
)
?
"other"
:
gatherName
.
toLowerCase
();
return
new
StringBuilder
(
"oss/"
).
append
(
uploadType
).
append
(
"/"
).
append
(
gatherName
).
append
(
"/"
).
append
(
fileType
)
.
append
(
"/"
).
append
(
fileName
).
append
(
"."
).
append
(
fileType
).
toString
();
}
/**
/**
* 获取文件下载加密密钥,默认有效期48小时 <br>
* 获取文件下载加密密钥,默认有效期48小时 <br>
* 密钥需要结合域名https://download.5rs.me使用,可以在浏览器直接下载 <br>
* 密钥需要结合域名https://download.5rs.me使用,可以在浏览器直接下载 <br>
...
...
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