//package com.iplatform.file;
|
//
|
//import com.iplatform.file.support.AwsOssFileEngine;
|
//import com.walker.infrastructure.utils.FileCopyUtils;
|
//import org.junit.Test;
|
//
|
//import java.io.File;
|
//import java.io.FileInputStream;
|
//import java.io.InputStream;
|
//import java.util.concurrent.TimeUnit;
|
//
|
//public class TestOss {
|
//
|
// /**
|
// * 2:后下载,根据1中生成的key,获取文件内容
|
// * @throws Exception
|
// */
|
//// @Test
|
// public void downloadFile() throws Exception{
|
// String id = "1064987848085008";
|
// AwsOssFileEngine engine = this.awsOssFileEngine();
|
//// byte[] content = engine.downloadFile(id);
|
// byte[] content = engine.testDownload(id);
|
//// FileUtils.writeFile(content, "f:/图片/test_oss_down.jpg");
|
//// FileCopyUtils.copy(content, new File("f:/图片/test_oss_down.jpg"));
|
// FileCopyUtils.copy(content, new File("f:/图片/corda_1.zip"));
|
//
|
// TimeUnit.SECONDS.sleep(10);
|
//
|
// content = engine.testDownload(id);
|
// FileCopyUtils.copy(content, new File("f:/图片/corda_2.zip"));
|
// }
|
//
|
// /**
|
// * 1:先上传,控制台获取key
|
// * @throws Exception
|
// */
|
// @Test
|
// public void uploadFile() throws Exception{
|
// String fileName = "f:/图片/3300.jpg_wh1200.jpg";
|
//// String fileName = "D:/360极速浏览器下载/corda-release-os-4.12.zip";
|
// AwsOssFileEngine engine = this.awsOssFileEngine();
|
//// engine.uploadFile("f:/图片/3300.jpg_wh1200.jpg", null);
|
// InputStream inputStream = new FileInputStream(fileName);
|
// engine.uploadFile(inputStream, "3300.jpg_wh1200.jpg", "", (long)inputStream.available(), 0, "-1");
|
//
|
// TimeUnit.SECONDS.sleep(5);
|
//
|
// fileName = "D:/360极速浏览器下载/corda-release-os-4.12.zip";
|
// inputStream = new FileInputStream(fileName);
|
// engine.uploadFile(inputStream, "corda-release-os-4.12.zip", "", (long)inputStream.available(), 0, "-1");
|
//
|
// engine.close();
|
// }
|
//
|
// private AwsOssFileEngine awsOssFileEngine(){
|
// AwsOssFileEngine engine = new AwsOssFileEngine();
|
// engine.setAccessKey("HDKSYC2Y4FELF5CL5FIB");
|
// engine.setSecretKey("ktf8Px9uTvLFFpQNGsO41ehRsgJ0hWnLtxZnDBCX");
|
// engine.setEndpoint("http://eos-beijing-1.cmecloud.cn");
|
// engine.setBucketName("ctoms-file");
|
// engine.initS3Client();
|
// return engine;
|
// }
|
//}
|