Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
0627802c
Commit
0627802c
authored
Aug 10, 2018
by
Junling Bu
Browse files
fix[litemall-core]: 七牛存储里面的上传凭证实时生成
parent
c6ed4cb4
Changes
1
Hide whitespace changes
Inline
Side-by-side
litemall-core/src/main/java/org/linlinjava/litemall/core/storage/QiniuStorage.java
View file @
0627802c
...
@@ -21,7 +21,7 @@ public class QiniuStorage implements Storage {
...
@@ -21,7 +21,7 @@ public class QiniuStorage implements Storage {
private
String
accessKey
;
private
String
accessKey
;
private
String
secretKey
;
private
String
secretKey
;
private
String
bucketName
;
private
String
bucketName
;
private
String
upToken
;
private
Auth
auth
;
private
UploadManager
uploadManager
;
private
UploadManager
uploadManager
;
private
BucketManager
bucketManager
;
private
BucketManager
bucketManager
;
...
@@ -63,12 +63,14 @@ public class QiniuStorage implements Storage {
...
@@ -63,12 +63,14 @@ public class QiniuStorage implements Storage {
@Override
@Override
public
void
store
(
InputStream
inputStream
,
long
contentLength
,
String
contentType
,
String
keyName
)
{
public
void
store
(
InputStream
inputStream
,
long
contentLength
,
String
contentType
,
String
keyName
)
{
if
(
uploadManager
==
null
){
if
(
uploadManager
==
null
){
if
(
auth
==
null
)
{
auth
=
Auth
.
create
(
accessKey
,
secretKey
);
}
uploadManager
=
new
UploadManager
(
new
Configuration
());
uploadManager
=
new
UploadManager
(
new
Configuration
());
Auth
auth
=
Auth
.
create
(
accessKey
,
secretKey
);
upToken
=
auth
.
uploadToken
(
bucketName
);
}
}
try
{
try
{
String
upToken
=
auth
.
uploadToken
(
bucketName
);
Response
response
=
uploadManager
.
put
(
inputStream
,
keyName
,
upToken
,
null
,
contentType
);
Response
response
=
uploadManager
.
put
(
inputStream
,
keyName
,
upToken
,
null
,
contentType
);
}
catch
(
QiniuException
ex
)
{
}
catch
(
QiniuException
ex
)
{
ex
.
printStackTrace
();
ex
.
printStackTrace
();
...
@@ -104,7 +106,9 @@ public class QiniuStorage implements Storage {
...
@@ -104,7 +106,9 @@ public class QiniuStorage implements Storage {
@Override
@Override
public
void
delete
(
String
keyName
)
{
public
void
delete
(
String
keyName
)
{
if
(
bucketManager
==
null
){
if
(
bucketManager
==
null
){
Auth
auth
=
Auth
.
create
(
accessKey
,
secretKey
);
if
(
auth
==
null
)
{
auth
=
Auth
.
create
(
accessKey
,
secretKey
);
}
bucketManager
=
new
BucketManager
(
auth
,
new
Configuration
()
);
bucketManager
=
new
BucketManager
(
auth
,
new
Configuration
()
);
}
}
...
...
Write
Preview
Supports
Markdown
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