尝试给OSS限速,好像失败了
This commit is contained in:
parent
8491879c2a
commit
3fcf1e72cc
@ -12,7 +12,7 @@ import org.springframework.context.annotation.Import;
|
||||
@Import(BTDownloadManager.class)
|
||||
@SpringBootApplication
|
||||
public class NasApplication {
|
||||
public static final String version="1.1.4";
|
||||
public static final String version="1.1.4.2";
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(NasApplication.class, args);
|
||||
AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
|
||||
|
@ -13,8 +13,12 @@ public class DepotManager {
|
||||
private DepotManager() {
|
||||
|
||||
}
|
||||
|
||||
public static void scan() {
|
||||
String str=HttpTools.get("http://tools.yutou233.cn/nas/depot/list.do");
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String str = HttpTools.get("http://tools.yutou233.cn/nas/depot/list.do?token=" + HttpTools.serverKey);
|
||||
if (!StringUtils.isEmpty(str)) {
|
||||
JSONObject json = JSONObject.parseObject(str);
|
||||
if (json.getInteger("code") == 1) {
|
||||
@ -32,6 +36,10 @@ public class DepotManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
private static void scanFile(File path, DownloadInterface interfaces) {
|
||||
if (!path.exists()) {
|
||||
interfaces.onError(new FileNotFoundException("没有该文件"));
|
||||
|
@ -12,6 +12,7 @@ import java.net.URLEncoder;
|
||||
import java.util.Set;
|
||||
|
||||
public class HttpTools {
|
||||
public static final String serverKey="zIrsh9TUZP2lfRW753PannG49E7VJvor";
|
||||
public static String get(String url) {
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
|
@ -4,6 +4,7 @@ import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.model.OSSObject;
|
||||
import com.aliyun.oss.model.ObjectMetadata;
|
||||
import com.aliyun.oss.model.PutObjectRequest;
|
||||
import com.aliyun.oss.model.StorageClass;
|
||||
import com.yutou.nas.interfaces.DownloadInterface;
|
||||
|
||||
@ -61,7 +62,11 @@ public class OSSManager {
|
||||
return;
|
||||
}
|
||||
|
||||
client.putObject(ConfigTools.load(ConfigTools.CONFIG,type,String.class), uploadPath, file);
|
||||
//client.putObject(ConfigTools.load(ConfigTools.CONFIG,type,String.class), uploadPath, file);
|
||||
int limitSpeed = 100 * 1024 * 8;
|
||||
PutObjectRequest request=new PutObjectRequest(ConfigTools.load(ConfigTools.CONFIG,type,String.class),uploadPath,file);
|
||||
request.setTrafficLimit(limitSpeed);
|
||||
client.putObject(request);
|
||||
System.out.println(file.getName()+"已上传");
|
||||
}
|
||||
closeClient(client);
|
||||
|
Loading…
Reference in New Issue
Block a user