• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OSSClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.aliyun.openservices.oss.OSSClient的典型用法代码示例。如果您正苦于以下问题:Java OSSClient类的具体用法?Java OSSClient怎么用?Java OSSClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OSSClient类属于com.aliyun.openservices.oss包,在下文中一共展示了OSSClient类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: upload

import com.aliyun.openservices.oss.OSSClient; //导入依赖的package包/类
@Override
public void upload(String path, File file, String contentType) {
	PluginConfig pluginConfig = getPluginConfig();
	if (pluginConfig != null) {
		String accessId = pluginConfig.getAttribute("accessId");
		String accessKey = pluginConfig.getAttribute("accessKey");
		String bucketName = pluginConfig.getAttribute("bucketName");
		InputStream inputStream = null;
		try {
			inputStream = new FileInputStream(file);
			OSSClient ossClient = new OSSClient(accessId, accessKey);
			ObjectMetadata objectMetadata = new ObjectMetadata();
			objectMetadata.setContentType(contentType);
			objectMetadata.setContentLength(file.length());
			ossClient.putObject(bucketName, StringUtils.removeStart(path, "/"), inputStream, objectMetadata);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			IOUtils.closeQuietly(inputStream);
		}
	}
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:23,代码来源:OssPlugin.java


示例2: add

import com.aliyun.openservices.oss.OSSClient; //导入依赖的package包/类
@Override
public String add(InputStream input, String dir, String filename, long lenght, String contentType) throws IOException {
	if (input == null) {
		throw new NullPointerException("input不能为空.");
	}
	
	OSSClient client = new OSSClient(endpoint, accessKeyId, secretAccessKey);
	// System.err.println("endpoint:" + endpoint);
	ObjectMetadata meta = new ObjectMetadata();
	meta.setContentLength(lenght);
	if (contentType != null) {
		meta.setContentType(contentType);
	}
	filename = toUuidFileName(filename);
	String uri;
	if (dir == null || dir.length() == 0) {
		uri = filename;
	}
	else {
		uri = dir + "/" + filename;
	}
	System.out.println("uri:" + uri + " lenght:" + lenght);
	PutObjectResult result = client.putObject(bucketName, uri, input, meta);
	System.out.println(result.getETag());
	return "/" + uri;
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:27,代码来源:OssClientImpl.java


示例3: save

import com.aliyun.openservices.oss.OSSClient; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public String save(GenericFile genericFile){
	OSSClient client = new OSSClient(accessKeyId, accessKeySecret);
	if(!client.doesBucketExist(bucketName)){
		client.createBucket(bucketName);
	}
	ObjectMetadata metadata = new ObjectMetadata();
	metadata.setContentLength(genericFile.getLength());
	if(fileNameGenerator == null){
		throw new RuntimeException("no file name generator configed");
	}
	String path = fileNameGenerator.gen() + genericFile.getExtend();
	client.putObject(bucketName, path, genericFile.getIs(), metadata);
	return path;
}
 
开发者ID:shangtech,项目名称:shangtech-framework,代码行数:17,代码来源:AliOSSFileSaver.java


示例4: getRootFolder

import com.aliyun.openservices.oss.OSSClient; //导入依赖的package包/类
public StorageFolder getRootFolder() {
    if (root == null) {
        StorageBucket bucket = bucketService.singleFileBucket();
        OSSClient client = new OSSClient(bucket.getUploadUrl(), bucket.getAccessKeyId(),
            bucket.getAccessKeySecret());
        root = StorageFolder.getRootFolder(client, bucket.getName());
    }
    return root;
}
 
开发者ID:mba811,项目名称:loli.io,代码行数:10,代码来源:StorageFolders.java


示例5: initialize

import com.aliyun.openservices.oss.OSSClient; //导入依赖的package包/类
@Override
public void initialize(URI uri, Configuration conf) throws IOException {
  uri = checkNotNull(uri);
  conf = checkNotNull(conf);

  OSSCredentials ossCredentials = new OSSCredentials();
  ossCredentials.initialize(uri, conf);

  client = new OSSClient(ossCredentials.getAccessKeyId(), ossCredentials.getSecretAccessKey());
  bucket = checkNotNull(uri.getHost(), "URI must include a host: %s", uri);

  // TODO deal with server-side encryption for store, copy
  multiPartUploader = new MultiPartUploader(client, bucket, conf);
}
 
开发者ID:quixey,项目名称:dragon-oss,代码行数:15,代码来源:CloudOSSFileSystemStore.java


示例6: MultiPartUploader

import com.aliyun.openservices.oss.OSSClient; //导入依赖的package包/类
MultiPartUploader(OSSClient client, String bucket, Configuration conf) {
  this.client = checkNotNull(client);
  this.bucket = checkNotNull(bucket);

  checkNotNull(conf);

  multipartEnabled = conf.getBoolean(OSSFileSystemConfigKeys.OSS_MULTIPART_UPLOADS_ENABLED, true);
  partSize = conf.getLong(OSS_MULTIPART_UPLOADS_BLOCK_SIZE_PROPERTY, DEFAULT_MULTIPART_BLOCK_SIZE);
  maxThreads = conf.getInt(OSS_MULTIPART_UPLOADS_MAX_THREADS_PROPERTY, Integer.MAX_VALUE);

  checkArgument(partSize <= MAX_PART_SIZE, "%s must be at most %s", OSS_MULTIPART_UPLOADS_BLOCK_SIZE_PROPERTY, MAX_PART_SIZE);
}
 
开发者ID:quixey,项目名称:dragon-oss,代码行数:13,代码来源:MultiPartUploader.java


示例7: delete

import com.aliyun.openservices.oss.OSSClient; //导入依赖的package包/类
@Override
public void delete(String file) {
    OSSClient client = new OSSClient(uploadUrl, accessKeyId, accessKeySecret);
    client.deleteObject(bucketName, file);
}
 
开发者ID:mba811,项目名称:loli.io,代码行数:6,代码来源:AliStorageUploader.java


示例8: setUp

import com.aliyun.openservices.oss.OSSClient; //导入依赖的package包/类
@Before
public void setUp() {
  client = mock(OSSClient.class);
  Configuration conf = new Configuration();
  uploader = new MultiPartUploader(client, bucket, conf);
}
 
开发者ID:quixey,项目名称:dragon-oss,代码行数:7,代码来源:MultiPartUploaderTest.java


示例9: init

import com.aliyun.openservices.oss.OSSClient; //导入依赖的package包/类
@PostConstruct
public void init() {
    client = new OSSClient(url, key,
            secret);
}
 
开发者ID:chocotan,项目名称:lolibox,代码行数:6,代码来源:AliStorageService.java


示例10: getClient

import com.aliyun.openservices.oss.OSSClient; //导入依赖的package包/类
public OSSClient getClient() {
    return client;
}
 
开发者ID:chocotan,项目名称:lolibox,代码行数:4,代码来源:AliStorageService.java


示例11: setClient

import com.aliyun.openservices.oss.OSSClient; //导入依赖的package包/类
public void setClient(OSSClient client) {
    this.client = client;
}
 
开发者ID:chocotan,项目名称:lolibox,代码行数:4,代码来源:AliStorageService.java



注:本文中的com.aliyun.openservices.oss.OSSClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MIMEMessage类代码示例发布时间:2022-05-23
下一篇:
Java TypeIds类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap