Package com.amazon.s3

Examples of com.amazon.s3.GetStreamResponse


      System.out.println("Usage: bucket-list -prefix=<prefix> -delimiter=<delimiter> -marker=<Marker> -max=<max items to return> <bucket name>");
      System.exit(0);
    }
   
      try {
        ListBucket request = new ListBucket();
        Map<String, String> params = getNamedParameters(args);
       
        request.setBucket(args[args.length - 1]);
        request.setCredential("TODO");
        if(params.get("prefix") != null)
          request.setPrefix(params.get("prefix"));
        if(params.get("delimiter") != null)
          request.setDelimiter(params.get("delimiter"));
        if(params.get("marker") != null)
          request.setMarker(params.get("marker"));
        if(params.get("max") != null) {
          try {
            int maxKeys = Integer.parseInt(params.get("max"));
              request.setMaxKeys(maxKeys);
          } catch(Exception e){
            System.out.println("-max parameter should be a numeric value");
          }
        }
      request.setAWSAccessKeyId("TODO");
      request.setCredential("TODO");
      request.setSignature("TODO");
      request.setTimestamp(Calendar.getInstance());
     
      ListBucketResponse response = serviceStub.listBucket(request);
      ListBucketResult result = response.getListBucketResponse();
      System.out.println("\tContent of Bucket " + result.getName());
      System.out.println("\tListing with prefix: " + result.getPrefix() + ", delimiter: "
View Full Code Here


      request.setAWSAccessKeyId("TODO");
      request.setCredential("TODO");
      request.setSignature("TODO");
      request.setTimestamp(Calendar.getInstance());
     
      ListBucketResponse response = serviceStub.listBucket(request);
      ListBucketResult result = response.getListBucketResponse();
      System.out.println("\tContent of Bucket " + result.getName());
      System.out.println("\tListing with prefix: " + result.getPrefix() + ", delimiter: "
        + result.getDelimiter() + ", marker: " + result.getMarker() + ", max: " + result.getMaxKeys());
     
      ListEntry[] entries = result.getContents();
View Full Code Here

      request.setCredential("TODO");
      request.setSignature("TODO");
      request.setTimestamp(Calendar.getInstance());
     
      ListBucketResponse response = serviceStub.listBucket(request);
      ListBucketResult result = response.getListBucketResponse();
      System.out.println("\tContent of Bucket " + result.getName());
      System.out.println("\tListing with prefix: " + result.getPrefix() + ", delimiter: "
        + result.getDelimiter() + ", marker: " + result.getMarker() + ", max: " + result.getMaxKeys());
     
      ListEntry[] entries = result.getContents();
      if(entries != null) {
        for(int i = 0; i < entries.length; i++) {
          ListEntry entry = entries[i];
          System.out.print("\t");
          System.out.print(entry.getSize());
          System.out.print("\t");
          System.out.print(entry.getKey());
          System.out.print("\t");
          System.out.print(entry.getETag());
          System.out.print("\n");
        }
      }
     
      PrefixEntry[] prefixEntries = result.getCommonPrefixes();
      if(prefixEntries != null) {
        System.out.print("\n\n");
       
        for(int i = 0; i < prefixEntries.length; i++) {
          System.out.print("\t<Prefix>\t");
View Full Code Here

        + result.getDelimiter() + ", marker: " + result.getMarker() + ", max: " + result.getMaxKeys());
     
      ListEntry[] entries = result.getContents();
      if(entries != null) {
        for(int i = 0; i < entries.length; i++) {
          ListEntry entry = entries[i];
          System.out.print("\t");
          System.out.print(entry.getSize());
          System.out.print("\t");
          System.out.print(entry.getKey());
          System.out.print("\t");
          System.out.print(entry.getETag());
          System.out.print("\n");
        }
      }
     
      PrefixEntry[] prefixEntries = result.getCommonPrefixes();
View Full Code Here

      System.out.println("Unable to find file " + args[args.length -1]);
      System.exit(0);
    }
   
    try {
      PutObjectInline request = new PutObjectInline();
      request.setBucket(params.get("bucket"));
      request.setKey(params.get("name"));
      request.setContentLength(file.length());
      request.setAWSAccessKeyId("TODO");
      request.setCredential("TODO");
      request.setSignature("TODO");
      request.setTimestamp(Calendar.getInstance());
      request.setData(new DataHandler(file.toURL()));
     
      PutObjectInlineResponse response = serviceStub.putObjectInline(request);
        System.out.println("Object has been posted successfully. ETag: " + response.getPutObjectInlineResponse().getETag());
    } catch(Exception e) {
        System.out.println("Failed to execute object-put-inline due to " + e.getMessage());
View Full Code Here

      request.setCredential("TODO");
      request.setSignature("TODO");
      request.setTimestamp(Calendar.getInstance());
      request.setData(new DataHandler(file.toURL()));
     
      PutObjectInlineResponse response = serviceStub.putObjectInline(request);
        System.out.println("Object has been posted successfully. ETag: " + response.getPutObjectInlineResponse().getETag());
    } catch(Exception e) {
        System.out.println("Failed to execute object-put-inline due to " + e.getMessage());
    }
  }
View Full Code Here

        request.setBucket(args[1]);
        request.setSignature("TODO");
        request.setTimestamp(Calendar.getInstance());
       
        DeleteBucketResponse response = serviceStub.deleteBucket(request);
        Status status = response.getDeleteBucketResponse();
        if(status.getCode() == 200) {
          System.out.println("Bucket " + args[1] + " has been deleted successfully");
        } else {
          System.out.println("Unable to delete bucket " + args[1] + " - " + status.getDescription());
        }
      } catch(Exception e) {
        System.out.println("Failed to execute bucket-delete due to " + e.getMessage());
      }
  }
View Full Code Here

    * Returns a map containing all key-value pairs for the given FQN, or null
    * if the node is not present.
    */
   public Map get(Fqn name) throws Exception
   {
      GetStreamResponse response = connection.getStream(getBucket(), key(name));
      try
      {
         if (trace)
         {
            log.trace("get " + name + " response=" + response);
         }

         if (response.isNotFound())
            return null;
         if (!response.isOk())
            throw new S3Exception("get failed " + response);

         BufferedInputStream is = new BufferedInputStream(response.getInputStream());
         Map map = (Map) getMarshaller().objectFromStream(is);
         response.release();
         return map;
      }
      finally
      {
         response.release();
      }
   }
View Full Code Here

    * Returns a map containing all key-value pairs for the given FQN, or null
    * if the node is not present.
    */
   public Map get(Fqn name) throws Exception
   {
      GetStreamResponse response = connection.getStream(getBucket(), key(name));
      try
      {
         if (trace)
         {
            log.trace("get " + name + " response=" + response);
         }

         if (response.isNotFound())
            return null;
         if (!response.isOk())
            throw new S3Exception("get failed " + response);

         BufferedInputStream is = new BufferedInputStream(response.getInputStream());
         Map map = (Map) getMarshaller().objectFromStream(is);
         response.release();
         return map;
      }
      finally
      {
         response.release();
      }
   }
View Full Code Here

    * Returns a map containing all key-value pairs for the given FQN, or null
    * if the node is not present.
    */
   public Map get(Fqn name) throws Exception
   {
      GetStreamResponse response = connection.getStream(getBucket(), key(name));
      try
      {
         if (trace)
         {
            log.trace("get " + name + " response=" + response);
         }

         if (response.isNotFound())
            return null;
         if (!response.isOk())
            throw new S3Exception("get failed " + response);

         BufferedInputStream is = new BufferedInputStream(response.getInputStream());
         Map map = (Map) getMarshaller().objectFromStream(is);
         response.release();
         return map;
      }
      finally
      {
         response.release();
      }
   }
View Full Code Here

TOP

Related Classes of com.amazon.s3.GetStreamResponse

Copyright © 2018 www.massapicom. 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.