Examples of ObjectListing


Examples of com.amazonaws.services.s3.model.ObjectListing

        });
    }

    @Override public ImmutableMap<String, BlobMetaData> listBlobsByPrefix(@Nullable String blobNamePrefix) throws IOException {
        ImmutableMap.Builder<String, BlobMetaData> blobsBuilder = ImmutableMap.builder();
        ObjectListing prevListing = null;
        while (true) {
            ObjectListing list;
            if (prevListing != null) {
                list = blobStore.client().listNextBatchOfObjects(prevListing);
            } else {
                if (blobNamePrefix != null) {
                    list = blobStore.client().listObjects(blobStore.bucket(), buildKey(blobNamePrefix));
                } else {
                    list = blobStore.client().listObjects(blobStore.bucket(), keyPath);
                }
            }
            for (S3ObjectSummary summary : list.getObjectSummaries()) {
                String name = summary.getKey().substring(keyPath.length());
                blobsBuilder.put(name, new PlainBlobMetaData(name, summary.getSize()));
            }
            if (list.isTruncated()) {
                prevListing = list;
            } else {
                break;
            }
        }
View Full Code Here

Examples of com.amazonaws.services.s3.model.ObjectListing

        ListObjectsRequest listObjectsRequest = new ListObjectsRequest();
        listObjectsRequest.setBucketName(bucketName);
        listObjectsRequest.setPrefix(getConfiguration().getPrefix());
        listObjectsRequest.setMaxKeys(maxMessagesPerPoll);
       
        ObjectListing listObjects = getAmazonS3Client().listObjects(listObjectsRequest);
       
        LOG.trace("Found {} objects in bucket [{}]...", listObjects.getObjectSummaries().size(), bucketName);
       
        Queue<Exchange> exchanges = createExchanges(listObjects.getObjectSummaries());
        return processBatch(CastUtils.cast(exchanges));
    }
View Full Code Here

Examples of com.amazonaws.services.s3.model.ObjectListing


  public LinkedList<String> listNames(String prefix) throws StorageCloudException{

    LinkedList<String> find = new LinkedList<String>();
    ObjectListing objectListing = conn.listObjects(new ListObjectsRequest()
    .withBucketName(bucketName).withPrefix(prefix));
    for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
      find.add(objectSummary.getKey());
    }

    return find;
  }
View Full Code Here

Examples of com.amazonaws.services.s3.model.ObjectListing

  public String getDataIdByName(String sid, String name)
      throws StorageCloudException {
    try {
      if (lastContainer == null) {
        for (Bucket b : conn.listBuckets()) {
          ObjectListing keylist = conn.listObjects(b.getName());
          for (S3ObjectSummary eo : keylist.getObjectSummaries()) {       
            if (eo.getKey().equals(name)) {
              return name;
            }
          }
        }
      } else {
        ObjectListing keylist = conn.listObjects(lastContainer);
        for (S3ObjectSummary eo : keylist.getObjectSummaries()) {       
          if (eo.getKey().equals(name)) {
            lastContainer = null;
            return name;
          }
        }
View Full Code Here

Examples of com.amazonaws.services.s3.model.ObjectListing

    }else if(permission.equals("w")){
      acl.grantPermission(new CanonicalGrantee(canonicalId), Permission.Write);
    }

    if(!v && f){
      ObjectListing objectListing = conn.listObjects(cid);
      AccessControlList aclKeys = null;
      for(S3ObjectSummary elem: objectListing.getObjectSummaries()) {
        aclKeys = conn.getObjectAcl(cid, elem.getKey());
        aclKeys.grantPermission(new CanonicalGrantee(canonicalId), Permission.Read);
        aclKeys.grantPermission(new CanonicalGrantee(canonicalId), Permission.ReadAcp);
        conn.setObjectAcl(cid, elem.getKey(), aclKeys);
      }
View Full Code Here

Examples of com.amazonaws.services.s3.model.ObjectListing

            throws AmazonClientException, AmazonServiceException {
        assertParameterNotNull(previousObjectListing,
                "The previous object listing parameter must be specified when listing the next batch of objects in a bucket");

        if (!previousObjectListing.isTruncated()) {
            ObjectListing emptyListing = new ObjectListing();
            emptyListing.setBucketName(previousObjectListing.getBucketName());
            emptyListing.setDelimiter(previousObjectListing.getDelimiter());
            emptyListing.setMarker(previousObjectListing.getNextMarker());
            emptyListing.setMaxKeys(previousObjectListing.getMaxKeys());
            emptyListing.setPrefix(previousObjectListing.getPrefix());
            emptyListing.setEncodingType(previousObjectListing.getEncodingType());
            emptyListing.setTruncated(false);

            return emptyListing;
        }

        return listObjects(
View Full Code Here

Examples of com.amazonaws.services.s3.model.ObjectListing

    }

    /** S3 may paginate object lists; this will walk through all pages and produce full result list. */
    public static List<S3ObjectSummary> listAllObjects(AmazonS3 s3Session, ListObjectsRequest request) {
        List<S3ObjectSummary> allResults = new ArrayList<S3ObjectSummary>();
        ObjectListing result = s3Session.listObjects(request);
        allResults.addAll(result.getObjectSummaries());
        while (result.isTruncated()) {
            result = s3Session.listNextBatchOfObjects(result);
            allResults.addAll(result.getObjectSummaries());
        }
        return allResults;
    }
View Full Code Here

Examples of com.amazonaws.services.s3.model.ObjectListing

            throws AmazonClientException, AmazonServiceException {
        assertParameterNotNull(previousObjectListing,
                "The previous object listing parameter must be specified when listing the next batch of objects in a bucket");

        if (!previousObjectListing.isTruncated()) {
            ObjectListing emptyListing = new ObjectListing();
            emptyListing.setBucketName(previousObjectListing.getBucketName());
            emptyListing.setDelimiter(previousObjectListing.getDelimiter());
            emptyListing.setMarker(previousObjectListing.getNextMarker());
            emptyListing.setMaxKeys(previousObjectListing.getMaxKeys());
            emptyListing.setPrefix(previousObjectListing.getPrefix());
            emptyListing.setEncodingType(previousObjectListing.getEncodingType());
            emptyListing.setTruncated(false);

            return emptyListing;
        }
        return listObjects(new ListObjectsRequest(
                previousObjectListing.getBucketName(),
View Full Code Here

Examples of com.amazonaws.services.s3.model.ObjectListing

        long totalSize = 0;
        // Recurse all virtual subdirectories to get a list of object summaries.
        // This is a depth-first search.
        do {
            String prefix = commonPrefixes.pop();
            ObjectListing listObjectsResponse = null;

            do {
                if ( listObjectsResponse == null ) {
                    ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucketName)
                            .withDelimiter(DEFAULT_DELIMITER).withPrefix(prefix);
                    listObjectsResponse = s3.listObjects(listObjectsRequest);
                } else {
                    listObjectsResponse = s3.listNextBatchOfObjects(listObjectsResponse);
                }

                for ( S3ObjectSummary s : listObjectsResponse.getObjectSummaries() ) {
                    // Skip any files that are also virtual directories, since
                    // we can't save both a directory and a file of the same
                    // name.
                    if ( !s.getKey().equals(prefix)
                            && !listObjectsResponse.getCommonPrefixes().contains(s.getKey() + DEFAULT_DELIMITER) ) {
                        objectSummaries.add(s);
                        totalSize += s.getSize();
                    } else {
                        log.debug("Skipping download for object " + s.getKey()
                                + " since it is also a virtual directory");
                    }
                }

                commonPrefixes.addAll(listObjectsResponse.getCommonPrefixes());
            } while ( listObjectsResponse.isTruncated() );
        } while ( !commonPrefixes.isEmpty() );

        /* This is the hook for adding additional progress listeners */
        ProgressListenerChain additionalListeners = new ProgressListenerChain();

View Full Code Here

Examples of com.amazonaws.services.s3.model.ObjectListing

            throws AmazonClientException, AmazonServiceException {
        assertParameterNotNull(previousObjectListing,
                "The previous object listing parameter must be specified when listing the next batch of objects in a bucket");

        if (!previousObjectListing.isTruncated()) {
            ObjectListing emptyListing = new ObjectListing();
            emptyListing.setBucketName(previousObjectListing.getBucketName());
            emptyListing.setDelimiter(previousObjectListing.getDelimiter());
            emptyListing.setMarker(previousObjectListing.getNextMarker());
            emptyListing.setMaxKeys(previousObjectListing.getMaxKeys());
            emptyListing.setPrefix(previousObjectListing.getPrefix());
            emptyListing.setTruncated(false);

            return emptyListing;
        }

        return listObjects(new ListObjectsRequest(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.