You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package UnitTest;
import cn.hutool.core.io.FileUtil;
import com.dsideal.FengHuang.Util.HuaWeiOBSClient;
import com.jfinal.kit.PropKit;
import java.io.File;
public class UploadToOssForPreview {
/**
* 功能将文件上传到预览OBS位置
* 作者:黄海
* 时间2021-12-23
* @param filePath
*/
public static void uploadForPreview(String filePath) {
HuaWeiOBSClient obsClient = new HuaWeiOBSClient();
String KeyPrefix = "ccsjy-gtzz/";
File file = FileUtil.file(filePath);
obsClient.putObject(KeyPrefix + file.getName(), file);
obsClient.close();
}
public static void main(String[] args) {
//加载配置文件
PropKit.use("application.properties");
//上传预览文件
String filePath = "D:\\dsWork\\FengHuangJava\\src\\main\\resource\\Py\\演示文稿.pptx";
uploadForPreview(filePath);
//获取预览地址
File file = FileUtil.file(filePath);
String previewName = "https://ow365.cn/?i=14531&ssl=1&info=3&fname=" + file.getName() + "&furl=" + "https://video.edusoa.com/ccsjy-gtzz/" + file.getName();
System.out.println("在线打印地址:");
System.out.println(previewName);
previewName = previewName.replace("&info=3","");
System.out.println("预览地址:");
System.out.println(previewName);
}
}