Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
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
04b1e785
Commit
04b1e785
authored
Mar 20, 2021
by
liqin
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixed
parent
6c30f936
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
16 deletions
+8
-16
pom.xml
pom.xml
+5
-0
FastDFSUtils.java
...cn/wisenergy/chnmuseum/party/common/dfs/FastDFSUtils.java
+3
-16
No files found.
pom.xml
View file @
04b1e785
...
@@ -109,6 +109,11 @@
...
@@ -109,6 +109,11 @@
<version>
1.2.75
</version>
<version>
1.2.75
</version>
</dependency>
</dependency>
<!-- FastDFS -->
<!-- FastDFS -->
<dependency>
<groupId>
net.oschina.zcx7878
</groupId>
<artifactId>
fastdfs-client-java
</artifactId>
<version>
1.27.0.0
</version>
</dependency>
<dependency>
<dependency>
<groupId>
com.github.tobato
</groupId>
<groupId>
com.github.tobato
</groupId>
<artifactId>
fastdfs-client
</artifactId>
<artifactId>
fastdfs-client
</artifactId>
...
...
src/main/java/cn/wisenergy/chnmuseum/party/common/dfs/FastDFSUtils.java
View file @
04b1e785
...
@@ -185,19 +185,12 @@ public class FastDFSUtils {
...
@@ -185,19 +185,12 @@ public class FastDFSUtils {
public
static
String
uploadInputStream
(
InputStream
inStream
,
String
fileName
,
long
size
)
{
public
static
String
uploadInputStream
(
InputStream
inStream
,
String
fileName
,
long
size
)
{
String
[]
fileIds
;
String
[]
fileIds
;
try
{
try
{
// ClientGloble 读配置文件
// 老大客户端
TrackerClient
trackerClient
=
new
TrackerClient
();
TrackerServer
trackerServer
=
trackerClient
.
getConnection
();
StorageServer
storageServer
=
null
;
StorageClient
storageClient
=
new
StorageClient
(
trackerServer
,
storageServer
);
String
extName
=
FilenameUtils
.
getExtension
(
fileName
);
String
extName
=
FilenameUtils
.
getExtension
(
fileName
);
NameValuePair
[]
meta_list
=
new
NameValuePair
[
3
];
NameValuePair
[]
meta_list
=
new
NameValuePair
[
3
];
meta_list
[
0
]
=
new
NameValuePair
(
"fileName"
,
fileName
);
meta_list
[
0
]
=
new
NameValuePair
(
"fileName"
,
fileName
);
meta_list
[
1
]
=
new
NameValuePair
(
"fileExt"
,
extName
);
meta_list
[
1
]
=
new
NameValuePair
(
"fileExt"
,
extName
);
meta_list
[
2
]
=
new
NameValuePair
(
"fileSize"
,
String
.
valueOf
(
size
));
meta_list
[
2
]
=
new
NameValuePair
(
"fileSize"
,
String
.
valueOf
(
size
));
fileIds
=
storageClient
.
upload_file
(
null
,
size
,
new
FastDFSUtils
.
UploadFileSender
(
inStream
),
extName
,
meta_list
);
fileIds
=
getStorageClient
()
.
upload_file
(
null
,
size
,
new
FastDFSUtils
.
UploadFileSender
(
inStream
),
extName
,
meta_list
);
return
dfsFileAccessBasePath
+
"/"
+
fileIds
[
0
]
+
"/"
+
fileIds
[
1
];
return
dfsFileAccessBasePath
+
"/"
+
fileIds
[
0
]
+
"/"
+
fileIds
[
1
];
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -249,12 +242,7 @@ public class FastDFSUtils {
...
@@ -249,12 +242,7 @@ public class FastDFSUtils {
public
static
String
deletePic
(
String
[]
fileIds
)
{
public
static
String
deletePic
(
String
[]
fileIds
)
{
try
{
try
{
TrackerClient
tracker
=
new
TrackerClient
();
int
i
=
getStorageClient
().
delete_file
(
fileIds
[
0
],
fileIds
[
1
]);
TrackerServer
trackerServer
=
tracker
.
getConnection
();
StorageServer
storageServer
=
null
;
StorageClient
storageClient
=
new
StorageClient
(
trackerServer
,
storageServer
);
int
i
=
storageClient
.
delete_file
(
fileIds
[
0
],
fileIds
[
1
]);
System
.
out
.
println
(
i
==
0
?
"删除成功"
:
"删除失败:"
+
i
);
System
.
out
.
println
(
i
==
0
?
"删除成功"
:
"删除失败:"
+
i
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -263,8 +251,7 @@ public class FastDFSUtils {
...
@@ -263,8 +251,7 @@ public class FastDFSUtils {
}
}
private
static
class
UploadFileSender
implements
UploadCallback
{
private
static
class
UploadFileSender
implements
UploadCallback
{
private
final
InputStream
is
;
private
InputStream
is
;
public
UploadFileSender
(
InputStream
is
)
{
public
UploadFileSender
(
InputStream
is
)
{
this
.
is
=
is
;
this
.
is
=
is
;
...
...
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