OSS新增本地对比,线上API得要钱

This commit is contained in:
yutou 2021-06-22 15:39:53 +08:00
parent a1070c03ab
commit 93eab6b8a8
3 changed files with 11 additions and 2 deletions

View File

@ -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");

View File

@ -78,11 +78,18 @@ public class OSSManager {
uploadPath = uploadPath.substring(1);
}
String md5 = BinaryUtil.toBase64String(Tools.getFileMD5Byte(file));
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) {

View File

@ -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() {