本文整理汇总了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;未经允许,请勿转载。 |
请发表评论