Package org.jets3t.service.impl.rest.httpclient

Examples of org.jets3t.service.impl.rest.httpclient.RestS3Service


         */
        final String bucketName = "jets3t";
        final String delimiter = "/";

        AWSCredentials awsCredentials = SamplesUtils.loadAWSCredentials();
        S3Service restService = new RestS3Service(awsCredentials);

        final List allObjects = Collections.synchronizedList(new ArrayList());
        final Exception s3ServiceExceptions[] = new Exception[1];

        /*
         * Identify top-level "subdirectory" names in a bucket by performing a
         * standard object listing with a delimiter string.
         */
        long startTime = System.currentTimeMillis();

        // Find all the objects and common prefixes at the top level.
        StorageObjectsChunk initialChunk = restService.listObjectsChunked(
            bucketName, null, delimiter, 1000, null, true);

        long totalElapsedTime = System.currentTimeMillis() - startTime;

        // We will use the common prefix strings, if any, to perform sub-listings
View Full Code Here


    public static String createSignedUrl(String method, String bucketName, String objectKey,
        String specialParamName, Map<String, Object> headersMap, ProviderCredentials credentials,
        long secondsSinceEpoch, boolean isVirtualHost, boolean isHttps,
        boolean isDnsBucketNamingDisabled)
    {
        S3Service s3Service = new RestS3Service(credentials);
        return s3Service.createSignedUrl(method, bucketName, objectKey,
            specialParamName, headersMap, secondsSinceEpoch,
            isVirtualHost, isHttps, isDnsBucketNamingDisabled);
    }
View Full Code Here

        if (gatekeeperMessage.getApplicationProperties().containsKey("Prefix")) {
            prefix = gatekeeperMessage.getApplicationProperties().getProperty("Prefix");
        }

        // Construct an authorized service.
        RestS3Service service = new RestS3Service(credentials);

        // List objects in the configured bucket.
        S3Object[] objects = service.listObjects(s3BucketName, prefix, null, 1000);

        // Package object information in SignatureRequest objects. This data will be
        // automatically encoded and sent across the wire back to the client.
        for (int i = 0; i < objects.length; i++) {
            SignatureRequest sr = new SignatureRequest();
View Full Code Here

        if (missingInitParam) {
            throw new ServletException(errorMessage);
        }

        this.credentials = new AWSCredentials(awsAccessKey, awsSecretKey);
        this.s3Service = new RestS3Service(credentials);

        String secondsToSign = servletConfig.getInitParameter("SecondsToSign");
        if (secondsToSign == null || secondsToSign.length() == 0) {
            throw new ServletException("Missing required servlet init parameters for DefaultUrlSigner: "
                + "SecondsToSign");
View Full Code Here

                this);

        // Initialise a non-authenticated service.
        // Revert to anonymous service.
        s3ServiceMulti = new S3ServiceMulti(
                new RestS3Service(null, APPLICATION_DESCRIPTION, this), this);
    }
View Full Code Here

        } else {
            String userToken = args[4];
            String productToken = args[5];
            credentials = new AWSDevPayCredentials(accessKey, secretKey, userToken, productToken);
        }
        S3Service service = new RestS3Service(credentials);

        // Find all current multipart uploads
        List<MultipartUpload> multipartUploads =
            service.multipartListUploads(bucketName);

        // Identify only multipart uploads older than a certain date
        // (to try and avoid killing off an in-progress upload)
        long CUTOFF = System.currentTimeMillis() - (hoursAgo * 60 * 60 * 1000);
        List<MultipartUpload> oldMultipartUploads = new ArrayList<MultipartUpload>();
        for (MultipartUpload multipartUpload: multipartUploads) {
            if (multipartUpload.getInitiatedDate().getTime() < CUTOFF) {
                oldMultipartUploads.add(multipartUpload);
            }
        }
        System.out.println("Of " + multipartUploads.size() + " multipart upload(s) in "
            + bucketName + ", " + oldMultipartUploads.size() + " are older than "
            + hoursAgo + " hours ago");

        // If no candidates for deletion, no work to do
        if (oldMultipartUploads.size() < 1) {
            return;
        }

        // Prompt user to confirm deletion
        System.out.print("About to delete " + oldMultipartUploads.size()
            + " multipart uploads, is this OK? (y/n) ");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String response = br.readLine();
        if (!"y".equals(response.toLowerCase()) && !"yes".equals(response.toLowerCase())) {
            System.out.println("Aborting");
            return;
        }

        // Delete old multipart uploads
        for (MultipartUpload multipartUpload: oldMultipartUploads) {
            System.out.print("Deleting (aborting) " + multipartUpload + " ...");
            service.multipartAbortUpload(multipartUpload);
            System.out.println(" done.");
        }
    }
View Full Code Here

        String awsSecretKey = storageConfiguration.getSecretKey();

        AWSCredentials awsCredentials = new AWSCredentials(awsAccessKey, awsSecretKey);
        S3Service s3Service;
        try {
            s3Service = new RestS3Service(awsCredentials);
        } catch (S3ServiceException e) {
            log.error("S3ServiceException attempting to create RestS3Service");
            return null;
        }
        return s3Service;
View Full Code Here

    };
  }

  private void downloadThrows(final S3Artifact s3Artifact, final Path downloadTo) throws Exception {
    final S3Service s3 = new RestS3Service(new AWSCredentials(configuration.getS3AccessKey(), configuration.getS3SecretKey()));

    long length = 0;

    if (s3Artifact.getFilesize().isPresent()) {
      length = s3Artifact.getFilesize().get();
    } else {
      StorageObject details = s3.getObjectDetails(s3Artifact.getS3Bucket(), s3Artifact.getS3ObjectKey());

      Preconditions.checkNotNull(details, "Couldn't find object at %s/%s", s3Artifact.getS3Bucket(), s3Artifact.getS3ObjectKey());

      length = details.getContentLength();
    }
View Full Code Here

  public Optional<S3Service> s3Service(Optional<S3Configuration> config) throws S3ServiceException {
    if (!config.isPresent()) {
      return Optional.absent();
    }

    return Optional.<S3Service>of(new RestS3Service(new AWSCredentials(config.get().getS3AccessKey(), config.get().getS3SecretKey())));
  }
View Full Code Here

    this.metrics = metrics;

    this.fileSystem = FileSystems.getDefault();
    try {
      this.s3Service = new RestS3Service(new AWSCredentials(s3Configuration.getS3AccessKey(), s3Configuration.getS3SecretKey()));
    } catch (Throwable t) {
      throw Throwables.propagate(t);
    }

    this.jsonObjectFileHelper = jsonObjectFileHelper;
View Full Code Here

TOP

Related Classes of org.jets3t.service.impl.rest.httpclient.RestS3Service

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.