本文整理汇总了Java中com.aliyun.oss.OSSClient.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Java OSSClient.shutdown方法的具体用法?Java OSSClient.shutdown怎么用?Java OSSClient.shutdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.aliyun.oss.OSSClient
的用法示例。
在下文中一共展示了OSSClient.shutdown方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doPost
import com.aliyun.oss.OSSClient; //导入方法依赖的package包/类
public static String doPost(String id, MultipartFile multipartFile) throws IOException{
OSSClient ossClient = new OSSClient(endpoint,accessKeyId,accessKeySecret);
long currentTime = System.currentTimeMillis();
String filename = id + String.valueOf(currentTime)+".png";
//创建缓存文件
File f = null;
f = File.createTempFile("tmp", null);
multipartFile.transferTo(f);
//缓存文件上传至OSS
InputStream inputStream = new FileInputStream(f);
ossClient.putObject("zxbangban", filename, inputStream);
//关闭OSS实例,删除临时文件
ossClient.shutdown();
f.deleteOnExit();
return filename;
}
示例2: main
import com.aliyun.oss.OSSClient; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// endpoint以杭州为例,其它region请按实际情况填写
String endpoint = "http://oss-cn-beijing.aliyuncs.com";
// accessKey请登录https://ak-console.aliyun.com/#/查看
String accessKeyId = "aJz5xtsPpE9YeL8N";
String accessKeySecret = "qcoAmZWWNpraprwt9S6KbAGXiYploW";
ClientConfiguration conf = new ClientConfiguration();
// 设置OSSClient使用的最大连接数,默认1024
conf.setMaxConnections(200);
// 设置请求超时时间,默认50秒
conf.setSocketTimeout(10000);
// 设置失败请求重试次数,默认3次
conf.setMaxErrorRetry(5);
// 创建OSSClient实例
OSSClient client = new OSSClient(endpoint, accessKeyId, accessKeySecret, conf);
client.deleteObject("sourcod", "aa/cccccc.jpg");
// 使用访问OSS
// String content = "Hello OSS";
// PutObjectResult result = client.putObject("sourcod", "aa/cccccc.jpg", new URL("http://img2.hitumedia.com/validateImage/20161115/201611151602400098434.jpg").openStream());
// InputStream a = result.getCallbackResponseBody();
// System.out.println(result.getETag());
// 关闭client
client.shutdown();
}
示例3: createBucket
import com.aliyun.oss.OSSClient; //导入方法依赖的package包/类
public static void createBucket(String bucketName) {
OSSClient ossClient = newOSSClient();
try {
ossClient.createBucket(bucketName);
} finally {
ossClient.shutdown();
}
}
示例4: listBuckets
import com.aliyun.oss.OSSClient; //导入方法依赖的package包/类
public static List<Bucket> listBuckets() {
OSSClient ossClient = newOSSClient();
try {
return ossClient.listBuckets();
} finally {
ossClient.shutdown();
}
}
示例5: putObject
import com.aliyun.oss.OSSClient; //导入方法依赖的package包/类
/**
* 上传文件
*
* @param path 文件路径
* @param file 文件对象
*/
public static void putObject(String path, File file) {
OSSClient ossClient = newOSSClient();
try {
ossClient.putObject(bucketName, path, file);
} finally {
ossClient.shutdown();
}
}
示例6: listObjects
import com.aliyun.oss.OSSClient; //导入方法依赖的package包/类
public static ObjectListing listObjects(ListObjectsRequest listObjectsRequest) {
OSSClient ossClient = newOSSClient();
try {
return ossClient.listObjects(listObjectsRequest);
} finally {
ossClient.shutdown();
}
}
示例7: uploadOSS
import com.aliyun.oss.OSSClient; //导入方法依赖的package包/类
public static String uploadOSS(String BucketName, String name, InputStream is) {
// 创建OSSClient实例
OSSClient client = new OSSClient(endpoint, accessKeyId, accessKeySecret, conf);
// 使用访问OSS
if (StringUtils.isEmpty(name)) {
name = DateUtils.getDate("yyyyMMdd") + "/" + DateUtils.getDate("yyyyMMddHHmmssSSSS")
+ new Random().nextInt(1000) + ".jpg";
}
// 上传
client.putObject(BucketName, name, is);
// 关闭client
client.shutdown();
return ConfigUtil.getValueByKey("oss_head_url") + name;
}
示例8: doDelete
import com.aliyun.oss.OSSClient; //导入方法依赖的package包/类
public static void doDelete(String fileName) throws IOException{
OSSClient ossClient = new OSSClient(endpoint,accessKeyId,accessKeySecret);
ossClient.deleteObject("zxbangban",fileName);
ossClient.shutdown();
}
示例9: isExist
import com.aliyun.oss.OSSClient; //导入方法依赖的package包/类
public static boolean isExist(String filename) throws IOException{
OSSClient ossClient = new OSSClient(endpoint,accessKeyId,accessKeySecret);
boolean found = ossClient.doesObjectExist("zxbangban",filename);
ossClient.shutdown();
return found;
}