记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
董敬伟
liquidnet-bus-v1
Commits
09121561
Commit
09121561
authored
Apr 01, 2022
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nft修改购买逻辑
parent
2a53f70e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
GalaxyCommonBiz.java
...ava/com/liquidnet/service/galaxy/biz/GalaxyCommonBiz.java
+60
-0
No files found.
liquidnet-bus-service/liquidnet-service-galaxy/liquidnet-service-galaxy-impl/src/main/java/com/liquidnet/service/galaxy/biz/GalaxyCommonBiz.java
0 → 100644
View file @
09121561
package
com
.
liquidnet
.
service
.
galaxy
.
biz
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: GalaxyCommonBiz
* @Package com.liquidnet.service.galaxy.router.strategy.biz
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/23 11:20
*/
@Slf4j
@Component
public
class
GalaxyCommonBiz
{
@Value
(
"${liquidnet.galaxy.temp-file-path:/Users/anjiabin/mdsky_gitlab/galaxy/tempFilePath}"
)
private
String
tempFilePath
;
/**
* 通过URL上传
* @param url
* @param name
* @return
*/
public
File
inputStreamToFile
(
String
url
,
String
name
)
{
try
{
HttpURLConnection
httpUrl
=
(
HttpURLConnection
)
new
URL
(
url
).
openConnection
();
httpUrl
.
connect
();
InputStream
ins
=
httpUrl
.
getInputStream
();
// File file = new File(System.getProperty("java.io.tmpdir") + File.separator + name);
File
file
=
new
File
(
tempFilePath
+
File
.
separator
+
name
);
if
(
file
.
exists
())
{
return
file
;
}
OutputStream
os
=
new
FileOutputStream
(
file
);
int
bytesRead
;
int
len
=
8192
;
byte
[]
buffer
=
new
byte
[
len
];
while
((
bytesRead
=
ins
.
read
(
buffer
,
0
,
len
))
!=
-
1
)
{
os
.
write
(
buffer
,
0
,
bytesRead
);
}
os
.
close
();
ins
.
close
();
return
file
;
}
catch
(
Exception
e
)
{
log
.
error
(
"inputStreamToFileUrlError"
,
e
);
return
null
;
}
}
}
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