parent
6dd49551bb
commit
f7c121d911
@ -0,0 +1,21 @@
|
|||||||
|
package com.dsideal.YunXiaoTools.Cron4j;
|
||||||
|
|
||||||
|
import com.dsideal.YunXiaoTools.Start;
|
||||||
|
import com.dsideal.YunXiaoTools.Utils.ReadDataUtil;
|
||||||
|
import com.jfinal.plugin.cron4j.ITask;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
|
||||||
|
//0点任务
|
||||||
|
public class LingDianTask implements ITask {
|
||||||
|
@SneakyThrows
|
||||||
|
public void run() {
|
||||||
|
//如果是读取侧
|
||||||
|
if(Start.isMysql==1){
|
||||||
|
ReadDataUtil.doAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop() {
|
||||||
|
// 这里的代码会在 task 被关闭前调用
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.dsideal.YunXiaoTools.Utils;
|
||||||
|
|
||||||
|
import com.jfinal.kit.PropKit;
|
||||||
|
import com.obs.services.ObsClient;
|
||||||
|
import com.obs.services.model.PutObjectResult;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class ObsUtil {
|
||||||
|
/**
|
||||||
|
* 上传文件到华为云OBS
|
||||||
|
*/
|
||||||
|
public static void uploadToObs(String localFile, String objectKey) {
|
||||||
|
// 从配置文件中读取OBS配置
|
||||||
|
String endPoint = PropKit.get("obs_endpoint");
|
||||||
|
String ak = PropKit.get("obs_accessKeyId");
|
||||||
|
String sk = PropKit.get("obs_accessKeySecret");
|
||||||
|
String bucketName = PropKit.get("obs_bucket_name");
|
||||||
|
|
||||||
|
// 创建ObsClient实例
|
||||||
|
ObsClient obsClient = new ObsClient(ak, sk, endPoint);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 上传文件
|
||||||
|
PutObjectResult res=obsClient.putObject(bucketName, objectKey, new File(localFile));
|
||||||
|
System.out.println(res.getBucketName());
|
||||||
|
System.out.println(res.getObjectKey());
|
||||||
|
System.out.println("文件已上传到OBS: " + objectKey);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("上传文件到OBS失败: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
obsClient.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue