示例#1
0
 public void refreshObjectMeta(S3Object object) throws IOException {
   if (object.isTransient())
     throw new RuntimeException("transient object cannot updated, check transient status first");
   com.amazon.s3.S3Object obj = awsAuthConnection.head(name, object.getKey(), null).object;
   if (obj == null) object.setTransient(true);
   else object.setMeta(obj.metadata);
 }
示例#2
0
 public S3Object find(String key) throws IOException {
   for (S3Object obj : getObjects())
     if (obj.getKey().equals(key)) {
       obj.refreshMeta();
       return obj;
     }
   return null;
 }
示例#3
0
 /**
  * update data for the object
  *
  * @param object
  * @throws IOException
  */
 public void refreshObject(S3Object object) throws IOException {
   com.amazon.s3.S3Object obj = awsAuthConnection.get(name, object.getKey(), null).object;
   object.setTransient(obj == null);
   if (!object.isTransient()) {
     object.setData(obj.data);
     object.setMeta(obj.metadata);
   }
 }
示例#4
0
  public List<S3Object> getObjects() throws IOException {
    List<S3Object> retVal = new ArrayList<S3Object>();
    ListBucketResponse response = awsAuthConnection.listBucket(name, null, null, null, null);
    if (response != null) {
      for (Object be : response.getEntries()) {
        ListEntry le = (ListEntry) be;
        S3Object obj = S3Object.loadedFromServer(this, le.key);
        obj.setLastModified(le.lastModified);
        obj.setSize(le.size);
        retVal.add(obj);
      }
    }

    return retVal;
  }
示例#5
0
 public void removeObject(S3Object obj) throws IOException {
   Response response = awsAuthConnection.delete(name, obj.getKey(), null);
   response.assertSuccess();
 }
示例#6
0
 public void updateObjectMeta(S3Object obj) throws IOException {
   awsAuthConnection.copy(name, obj.getKey(), name, obj.getKey(), obj.getMeta(), null);
 }
示例#7
0
 public void saveObject(S3Object obj) throws IOException {
   obj.setBucket(this);
   com.amazon.s3.S3Object object = new com.amazon.s3.S3Object(obj.getData(), obj.getMeta());
   Response response = awsAuthConnection.put(name, obj.getKey(), object, null);
   response.assertSuccess();
 }
示例#8
0
 public String getSignedUrl(S3Object object) {
   queryStringGenerator.setExpiresIn(60000);
   return queryStringGenerator.get(name, object.getKey(), null);
 }