Skip to content

Commit 513ed87

Browse files
committed
七牛云图片根据用户名+时间戳生成
1 parent a3eb27c commit 513ed87

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

springboot-dubbo-web/src/main/java/com/lzq/web/utils/QiniuyunUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@ public static String uploadFiles(byte[] bytes) {
8080
return putRet.key;
8181
}
8282

83-
public static String uploadFile(File file) {
83+
public static String uploadFile(File file,String username) {
84+
long time = System.currentTimeMillis();
8485
//构造一个带指定 Region 对象的配置类
8586
Configuration cfg = new Configuration(Region.huanan());
8687
//...其他参数参考类注释
8788
UploadManager uploadManager = new UploadManager(cfg);
8889
//默认不指定key的情况下,以文件内容的hash值作为文件名
89-
String key = null;
90+
String key = username+time;
9091
Auth auth = Auth.create(ACCESSKEY, SECRETKEY);
9192
String upToken = auth.uploadToken(BUCKET);
9293

0 commit comments

Comments
 (0)