OSS新增本地对比,线上API得要钱
This commit is contained in:
parent
a1070c03ab
commit
93eab6b8a8
@ -12,7 +12,7 @@ import org.springframework.context.annotation.Import;
|
||||
@Import(BTDownloadManager.class)
|
||||
@SpringBootApplication
|
||||
public class NasApplication {
|
||||
public static final String version="1.1.5.1";
|
||||
public static final String version="1.1.6";
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(NasApplication.class, args);
|
||||
AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
|
||||
|
@ -78,11 +78,18 @@ public class OSSManager {
|
||||
uploadPath = uploadPath.substring(1);
|
||||
}
|
||||
String md5 = BinaryUtil.toBase64String(Tools.getFileMD5Byte(file));
|
||||
if (isExist(client, ConfigTools.load(ConfigTools.CONFIG, type, String.class), uploadPath, md5)) {
|
||||
Log.i("OSS", "文件已存在:" + file.getName());
|
||||
String redisMd5=RedisTools.get(file.getAbsolutePath(),RedisTools.DATABASES_ALI_OSS);
|
||||
if(!StringUtils.isEmpty(redisMd5)){
|
||||
if(redisMd5.equals(md5)){
|
||||
Log.i("OSS", "[本地]文件已存在:" + file.getName());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (isExist(client, ConfigTools.load(ConfigTools.CONFIG, type, String.class), uploadPath, md5)) {
|
||||
Log.i("OSS", "文件已存在:" + file.getName());
|
||||
RedisTools.set(RedisTools.DATABASES_ALI_OSS,file.getAbsolutePath(),md5);
|
||||
continue;
|
||||
}
|
||||
Log.i("OSS", "即将上传:" + file.getName());
|
||||
//client.putObject(ConfigTools.load(ConfigTools.CONFIG,type,String.class), uploadPath, file);
|
||||
int limitSpeed = 1024 * 1024 * 8;
|
||||
ObjectMetadata metadata = new ObjectMetadata();
|
||||
@ -113,6 +120,7 @@ public class OSSManager {
|
||||
});*/
|
||||
client.putObject(request);
|
||||
Log.i("OSS", file.getName() + "已上传");
|
||||
RedisTools.set(RedisTools.DATABASES_ALI_OSS,file.getAbsolutePath(),md5);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -19,6 +19,7 @@ public class RedisTools {
|
||||
private static String host;
|
||||
private static int port;
|
||||
public static int TOKEN_TIMEOUT_DEFAULT = 360;
|
||||
public final static int DATABASES_ALI_OSS=4;
|
||||
|
||||
private RedisTools() {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user