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
fd80760b
Commit
fd80760b
authored
Apr 06, 2019
by
Junling Bu
Browse files
fix[litemall-admin-api, litemall-core]: 对象存储返回对象存储信息,而不仅仅是图片链接
parent
520c9517
Changes
4
Hide whitespace changes
Inline
Side-by-side
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminStorageController.java
View file @
fd80760b
...
...
@@ -56,10 +56,8 @@ public class AdminStorageController {
@PostMapping
(
"/create"
)
public
Object
create
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
IOException
{
String
originalFilename
=
file
.
getOriginalFilename
();
String
url
=
storageService
.
store
(
file
.
getInputStream
(),
file
.
getSize
(),
file
.
getContentType
(),
originalFilename
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"url"
,
url
);
return
ResponseUtil
.
ok
(
data
);
LitemallStorage
litemallStorage
=
storageService
.
store
(
file
.
getInputStream
(),
file
.
getSize
(),
file
.
getContentType
(),
originalFilename
);
return
ResponseUtil
.
ok
(
litemallStorage
);
}
@RequiresPermissions
(
"admin:storage:read"
)
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/qcode/QCodeService.java
View file @
fd80760b
...
...
@@ -5,6 +5,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
import
org.linlinjava.litemall.core.storage.StorageService
;
import
org.linlinjava.litemall.core.system.SystemConfig
;
import
org.linlinjava.litemall.db.domain.LitemallGroupon
;
import
org.linlinjava.litemall.db.domain.LitemallStorage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.stereotype.Service
;
...
...
@@ -33,9 +34,9 @@ public class QCodeService {
byte
[]
imageData
=
drawPicture
(
inputStream
,
goodPicUrl
,
goodName
);
ByteArrayInputStream
inputStream2
=
new
ByteArrayInputStream
(
imageData
);
//存储分享图
String
url
=
storageService
.
store
(
inputStream2
,
imageData
.
length
,
"image/jpeg"
,
getKeyName
(
groupon
.
getId
().
toString
()));
LitemallStorage
storageInfo
=
storageService
.
store
(
inputStream2
,
imageData
.
length
,
"image/jpeg"
,
getKeyName
(
groupon
.
getId
().
toString
()));
return
url
;
return
storageInfo
.
getUrl
()
;
}
catch
(
WxErrorException
e
)
{
e
.
printStackTrace
();
}
catch
(
FileNotFoundException
e
)
{
...
...
@@ -67,9 +68,9 @@ public class QCodeService {
byte
[]
imageData
=
drawPicture
(
inputStream
,
goodPicUrl
,
goodName
);
ByteArrayInputStream
inputStream2
=
new
ByteArrayInputStream
(
imageData
);
//存储分享图
String
url
=
storageService
.
store
(
inputStream2
,
imageData
.
length
,
"image/jpeg"
,
getKeyName
(
goodId
));
LitemallStorage
litemallStorage
=
storageService
.
store
(
inputStream2
,
imageData
.
length
,
"image/jpeg"
,
getKeyName
(
goodId
));
return
url
;
return
litemallStorage
.
getUrl
()
;
}
catch
(
WxErrorException
e
)
{
e
.
printStackTrace
();
}
catch
(
FileNotFoundException
e
)
{
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/storage/StorageService.java
View file @
fd80760b
...
...
@@ -43,7 +43,7 @@ public class StorageService {
* @param contentType 文件类型
* @param fileName 文件索引名
*/
public
String
store
(
InputStream
inputStream
,
long
contentLength
,
String
contentType
,
String
fileName
)
{
public
LitemallStorage
store
(
InputStream
inputStream
,
long
contentLength
,
String
contentType
,
String
fileName
)
{
String
key
=
generateKey
(
fileName
);
storage
.
store
(
inputStream
,
contentLength
,
contentType
,
key
);
...
...
@@ -56,7 +56,7 @@ public class StorageService {
storageInfo
.
setUrl
(
url
);
litemallStorageService
.
add
(
storageInfo
);
return
url
;
return
storageInfo
;
}
private
String
generateKey
(
String
originalFilename
)
{
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxStorageController.java
View file @
fd80760b
...
...
@@ -53,11 +53,8 @@ public class WxStorageController {
@PostMapping
(
"/upload"
)
public
Object
upload
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
IOException
{
String
originalFilename
=
file
.
getOriginalFilename
();
String
url
=
storageService
.
store
(
file
.
getInputStream
(),
file
.
getSize
(),
file
.
getContentType
(),
originalFilename
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"url"
,
url
);
return
ResponseUtil
.
ok
(
data
);
LitemallStorage
litemallStorage
=
storageService
.
store
(
file
.
getInputStream
(),
file
.
getSize
(),
file
.
getContentType
(),
originalFilename
);
return
ResponseUtil
.
ok
(
litemallStorage
);
}
/**
...
...
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