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.
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|