public class StorageClient extends StorageBase implements Storage
  Storage是新浪云为开发者提供的分布式对象存储服务,旨在利用新浪云在分布式以及网络技术方面的优势为开发者提供安全、简单、高效的存储服务。
  Storage支持文本、多媒体、二进制等任何类型的数据的存储。
  仅限容器环境中
  
 
  使用样例:
  StroageClient sc = new StroageClient(); // 这里是默认构造,如果不使用当前应用下的storage可以调用传参数构造器new StroageClient(appname,ak,sk)
  //创建bucket 
  sc.createBucket("example_bucket"');
  //删除buckete 
  sc.deleteBucket("example_bucket");
  //获取相应bucket信息
  Bucket bucket = sc.getBucketInfo();
  //列出所有的bucket信息
  BucketList bucketList = sc.listBuckets();
  //获取bucket下所有的文件列表
  ObjectFileList objectFileList = sc.getBucket("example_bucket");
  //获取bucket下所有以example_prefix为前缀的文件列表 
  ObjectFileList objectFileList = sc.getBucket("example_bucket","example_prefix");
  //在storage上写一个文件,最后的参数不需要可以传null
  sc.putObjectFile("example_bucket","filename","content".getBytes(),metaMap);
  //上传一个文件,最后的参数不需要可以传null 
  sc.putObjectFile("example_bucket","filename",File,metaMap);
  //获取一个文件
  ObjectFile objcetFile = sc.getObject("example_bucket","filename");
  //删除一个文件
  sc.deleteObject("example_bucket","filename");
  
accessKey, appName, baseurl, DELETE, errMsg, errNo, GET, HEAD, HEADER_DATE_FORMAT, internal_timeout, NORMAL_DATE_FORMAT, POST, PUT, secretKey| 构造器和说明 | 
|---|
StorageClient()  | 
StorageClient(String appName,
             String accessKey,
             String secertKey)  | 
| 限定符和类型 | 方法和说明 | 
|---|---|
boolean | 
createBucket(String bucketName)
创建一个新的bucket 
 | 
boolean | 
deleteBucket(String bucketName)
删除指定的bucket 
 | 
boolean | 
deleteObject(String bucketName,
            String objectFileName)
删除指定的object 
 | 
ObjectFileList | 
getBucket(String bucketName)
列出提供的bucket下所有的object列表 
 | 
ObjectFileList | 
getBucket(String bucketName,
         String prefix)
列出提供的bucket下所有以 prefix 为前缀的object列表 
 | 
Bucket | 
getBucketInfo(String bucketName)
获取bucket相关的信息 
 | 
ObjectFile | 
getObject(String bucketName,
         String objectFileName)
获取提供的bucket下对应文件名的内容,如果需要获取bucket下某个文件夹的文件请使用"aa/bb"的形式传入文件名 
 | 
String | 
getTempUrl(String bucketName,
          String method,
          String objectName,
          int seconds)
获取一个object临时访问的URL 
 | 
BucketList | 
listBuckets()
列出当前用户下所有的bucket 
 | 
boolean | 
putObjectFile(String bucketName,
             String fileName,
             byte[] content,
             Map<String,String> map)
上传文件到指定的bucket下,content为你需要写入的内容,并且以byte[] 形式,map参数设置acl,如果没有可以直接传null 
如果需要put到bucket下某个文件夹下请使用"aa/bb"的形式传入文件名  | 
boolean | 
putObjectFile(String bucketName,
             String fileName,
             File file,
             Map<String,String> map)
上传文件到指定的bucket下,file需要已经上传到容器的某个位置,map参数设置acl,如果没有可以直接传null 
如果需要put到bucket下某个文件夹下请使用"aa/bb"的形式传入文件名  | 
getErrmsg, getErrnopublic boolean createBucket(String bucketName)
createBucket 在接口中 StoragebucketName - RuntimeException - {"the value of parameter  can not be empty!","the bucket has created","reach the upper limit of creating buckets"}IOExceptionpublic Bucket getBucketInfo(String bucketName)
getBucketInfo 在接口中 StoragebucketName - IOExceptionRuntimeException - "the value of parameter  can not be empty!"public BucketList listBuckets()
listBuckets 在接口中 StorageIOExceptionpublic ObjectFileList getBucket(String bucketName)
getBucket 在接口中 StoragebucketName - RuntimeException - "the value of parameter  can not be empty!"IOExceptionpublic ObjectFileList getBucket(String bucketName, String prefix)
getBucket 在接口中 StoragebucketName - prefix - RuntimeException - "the value of parameter  can not be empty!"IOExceptionpublic boolean deleteBucket(String bucketName)
deleteBucket 在接口中 StoragebucketName - RuntimeException - {"the value of parameter  can not be empty!","the bucket is not null","the bucket not found or has remove"}public boolean putObjectFile(String bucketName, String fileName, byte[] content, Map<String,String> map)
putObjectFile 在接口中 StoragebucketName - fileName - content - map - RuntimeException - {"the value of parameter  can not be empty!","the bucket not found or has remove"}public boolean putObjectFile(String bucketName, String fileName, File file, Map<String,String> map)
putObjectFile 在接口中 StoragebucketName - file - map - RuntimeException - {"the value of parameter  can not be empty!","file does not exist","the bucket not found or has remove"}public ObjectFile getObject(String bucketName, String objectFileName)
getObject 在接口中 StoragebucketName - objectFileName - RuntimeException - {"the value of parameter  can not be empty!","object file does not exist in the bucket or has removed"}public boolean deleteObject(String bucketName, String objectFileName)
deleteObject 在接口中 StoragebucketName - objectFileName - RuntimeException - {"the value of parameter  can not be empty!","object file does not exist in the bucket or has removed"}Copyright © 2016. All rights reserved.