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
9f32954a
Commit
9f32954a
authored
Jul 28, 2023
by
xushaohua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:部署
parent
2d470330
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
TaskController.java
...github/novicezk/midjourney/controller/TaskController.java
+10
-0
FileUtil.java
...in/java/com/github/novicezk/midjourney/util/FileUtil.java
+3
-0
No files found.
midjourney-proxy/src/main/java/com/github/novicezk/midjourney/controller/TaskController.java
View file @
9f32954a
package
com
.
github
.
novicezk
.
midjourney
.
controller
;
package
com
.
github
.
novicezk
.
midjourney
.
controller
;
import
cn.hutool.core.comparator.CompareUtil
;
import
cn.hutool.core.comparator.CompareUtil
;
import
cn.hutool.extra.spring.SpringUtil
;
import
com.github.novicezk.midjourney.dto.TaskConditionDTO
;
import
com.github.novicezk.midjourney.dto.TaskConditionDTO
;
import
com.github.novicezk.midjourney.service.TaskStoreService
;
import
com.github.novicezk.midjourney.service.TaskStoreService
;
import
com.github.novicezk.midjourney.support.Task
;
import
com.github.novicezk.midjourney.support.Task
;
import
com.github.novicezk.midjourney.support.TaskQueueHelper
;
import
com.github.novicezk.midjourney.support.TaskQueueHelper
;
import
com.github.novicezk.midjourney.util.FileUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
io.swagger.annotations.ApiParam
;
...
@@ -44,6 +46,14 @@ public class TaskController {
...
@@ -44,6 +46,14 @@ public class TaskController {
return
this
.
taskStoreService
.
get
(
id
);
return
this
.
taskStoreService
.
get
(
id
);
}
}
@ApiOperation
(
value
=
"转换url"
)
@GetMapping
(
"convertUrl"
)
public
String
convertUrl
(
String
url
)
{
FileUtil
fileUtil
=
SpringUtil
.
getBean
(
"fileUtil"
);
String
s
=
fileUtil
.
convertFile
(
url
);
return
s
;
}
@ApiOperation
(
value
=
"查询任务队列"
)
@ApiOperation
(
value
=
"查询任务队列"
)
@GetMapping
(
"/queue"
)
@GetMapping
(
"/queue"
)
public
List
<
Task
>
queue
()
{
public
List
<
Task
>
queue
()
{
...
...
midjourney-proxy/src/main/java/com/github/novicezk/midjourney/util/FileUtil.java
View file @
9f32954a
...
@@ -31,6 +31,7 @@ public class FileUtil {
...
@@ -31,6 +31,7 @@ public class FileUtil {
* @return
* @return
*/
*/
public
String
convertFile
(
String
discordUrl
)
{
public
String
convertFile
(
String
discordUrl
)
{
log
.
info
(
"开始转换图片:{}"
,
discordUrl
);
try
{
try
{
// 在线图片地址转换成base64
// 在线图片地址转换成base64
URL
url
=
new
URL
(
discordUrl
);
URL
url
=
new
URL
(
discordUrl
);
...
@@ -46,6 +47,7 @@ public class FileUtil {
...
@@ -46,6 +47,7 @@ public class FileUtil {
// 将字节数组输出流中的图片数据进行 Base64 编码
// 将字节数组输出流中的图片数据进行 Base64 编码
byte
[]
imageBytes
=
outputStream
.
toByteArray
();
byte
[]
imageBytes
=
outputStream
.
toByteArray
();
String
base64Data
=
Base64
.
getEncoder
().
encodeToString
(
imageBytes
);
String
base64Data
=
Base64
.
getEncoder
().
encodeToString
(
imageBytes
);
log
.
info
(
"下载转换成了base64:{}"
,
discordUrl
);
String
last
=
discordUrl
.
substring
(
discordUrl
.
lastIndexOf
(
"."
)
+
1
);
String
last
=
discordUrl
.
substring
(
discordUrl
.
lastIndexOf
(
"."
)
+
1
);
JSONObject
jsonObject
=
new
JSONObject
();
JSONObject
jsonObject
=
new
JSONObject
();
...
@@ -57,6 +59,7 @@ public class FileUtil {
...
@@ -57,6 +59,7 @@ public class FileUtil {
.
header
(
"content-type"
,
"application/json"
)
.
header
(
"content-type"
,
"application/json"
)
.
body
(
jsonObject
.
toString
(),
"application/json;charset=utf-8"
);
.
body
(
jsonObject
.
toString
(),
"application/json;charset=utf-8"
);
HttpResponse
httpResponse
=
request
.
execute
();
HttpResponse
httpResponse
=
request
.
execute
();
log
.
info
(
"调用远程上传接口返回:{}"
,
httpResponse
.
body
());
String
uploadUrl
=
Optional
.
ofNullable
(
httpResponse
.
body
())
String
uploadUrl
=
Optional
.
ofNullable
(
httpResponse
.
body
())
.
map
(
JSONObject:
:
new
)
.
map
(
JSONObject:
:
new
)
.
map
(
x
->
x
.
getJSONObject
(
"data"
))
.
map
(
x
->
x
.
getJSONObject
(
"data"
))
...
...
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