Java 类com.amazonaws.HttpMethod 实例源码

项目:carina    文件:AmazonS3Manager.java   
/**
 * Method to generate pre-signed object URL to s3 object
 * @param bucketName AWS S3 bucket name
 * @param key (example: android/apkFolder/ApkName.apk)
 * @param ms espiration time in ms, i.e. 1 hour is 1000*60*60
 * @return url String pre-signed URL
 */
public URL generatePreSignUrl(final String bucketName, final String key, long ms) {

    java.util.Date expiration = new java.util.Date();
    long msec = expiration.getTime();
    msec += ms;
    expiration.setTime(msec);

    GeneratePresignedUrlRequest generatePresignedUrlRequest = 
                  new GeneratePresignedUrlRequest(bucketName, key);
    generatePresignedUrlRequest.setMethod(HttpMethod.GET);
    generatePresignedUrlRequest.setExpiration(expiration);

    URL url = s3client.generatePresignedUrl(generatePresignedUrlRequest);
    return url;
}
项目:teamcity-s3-artifact-storage-plugin    文件:S3PreSignedUrlProviderImpl.java   
@NotNull
@Override
public String getPreSignedUrl(@NotNull HttpMethod httpMethod, @NotNull String bucketName, @NotNull String objectKey, @NotNull Map<String, String> params) throws IOException {
  try {
    final Callable<String> resolver = () -> S3Util.withS3Client(params, client -> {
      final GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucketName, objectKey, httpMethod)
        .withExpiration(new Date(System.currentTimeMillis() + getUrlLifetimeSec() * 1000));
      return client.generatePresignedUrl(request).toString();
    });
    if (httpMethod == HttpMethod.GET) {
      return TeamCityProperties.getBoolean(TEAMCITY_S3_PRESIGNURL_GET_CACHE_ENABLED)
        ? myGetLinksCache.get(getCacheIdentity(params, objectKey, bucketName), resolver)
        : resolver.call();
    } else {
      return resolver.call();
    }
  } catch (Exception e) {
    final AWSException awsException = new AWSException(e.getCause());
    if (StringUtil.isNotEmpty(awsException.getDetails())) {
      LOG.warn(awsException.getDetails());
    }
    final String err = "Failed to create " + httpMethod.name() + " pre-signed URL for [" + objectKey + "] in bucket [" + bucketName + "]";
    LOG.infoAndDebugDetails(err, awsException);
    throw new IOException(err + ": " + awsException.getMessage(), awsException);
  }
}
项目:teamcity-s3-artifact-storage-plugin    文件:S3ArtifactDownloadProcessor.java   
@Override
public boolean processDownload(@NotNull StoredBuildArtifactInfo storedBuildArtifactInfo,
                               @NotNull BuildPromotion buildPromotion,
                               @NotNull HttpServletRequest httpServletRequest,
                               @NotNull HttpServletResponse httpServletResponse) throws IOException {
  final ArtifactData artifactData = storedBuildArtifactInfo.getArtifactData();
  if (artifactData == null) throw new IOException("Can not process artifact download request for a folder");

  final Map<String, String> params = S3Util.validateParameters(storedBuildArtifactInfo.getStorageSettings());
  final String pathPrefix = S3Util.getPathPrefix(storedBuildArtifactInfo.getCommonProperties());

  final String bucketName = S3Util.getBucketName(params);
  if (bucketName == null) {
    final String message = "Failed to create pre-signed URL: bucket name is not specified, please check storage settings";
    LOG.warn(message);
    throw new IOException(message);
  }

  httpServletResponse.setHeader(HttpHeaders.CACHE_CONTROL, "max-age=" + myPreSignedUrlProvider.getUrlLifetimeSec());
  httpServletResponse.sendRedirect(myPreSignedUrlProvider.getPreSignedUrl(HttpMethod.valueOf(httpServletRequest.getMethod()), bucketName, pathPrefix + artifactData.getPath(),params));
  return true;
}
项目:hmftools    文件:SbpS3UrlGenerator.java   
@NotNull
static URL generateUrl(@NotNull final String bucketName, @NotNull final String objectKey) throws IOException {
    try {
        LOGGER.info("Generating pre-signed URL for bucket: {}\tobject: {}", bucketName, objectKey);
        final long millisNow = System.currentTimeMillis();
        final long expirationMillis = millisNow + 1000 * 60 * 120;   //add 2 hours;
        final Date expiration = new java.util.Date(expirationMillis);
        final GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, objectKey);
        generatePresignedUrlRequest.setMethod(HttpMethod.GET);
        generatePresignedUrlRequest.setExpiration(expiration);

        return s3Client.generatePresignedUrl(generatePresignedUrlRequest);
    } catch (AmazonServiceException exception) {
        LOGGER.error("Error Message: {}", exception.getMessage());
        LOGGER.error("HTTP  Code: {}", exception.getStatusCode());
        LOGGER.error("Error Code: {}", exception.getErrorCode());
        LOGGER.error("Error Type:   {}", exception.getErrorType());
        LOGGER.error("Request ID:   {}", exception.getRequestId());
    } catch (AmazonClientException ace) {
        LOGGER.error("The client encountered an internal error while trying to communicate with S3");
        LOGGER.error("Error Message: {}", ace.getMessage());
    }
    throw new IOException("Failed to create sbp URL.");
}
项目:cloudstorage    文件:S3CloudStorage.java   
/**
 * create url for a file which will expire in specified seconds.
 * 
 * @param bucket the bucket name
 * @param filename the filename
 * @param expirySeconds the number of seconds after which this url will expire
 * @return the url
 * @throws CloudException on AWS Service/Client errors
 */
public URL getExpiringUrl(String bucket, String filename, long expirySeconds) throws CloudException {
    checkArgument(! Strings.isNullOrEmpty(bucket), "bucket is null or empty");
    checkArgument(! Strings.isNullOrEmpty(filename), "filename is null or empty");
    checkArgument(expirySeconds > 0, "expirySeconds %d is not postive for bucket %s filename %s", 
            expirySeconds, bucket, filename);

    Date expiry = Instant.now().plus(Duration.standardSeconds(expirySeconds)).toDate();

    try {
        return urlGenS3.generatePresignedUrl(bucket, filename, expiry, HttpMethod.GET);
    } catch (AmazonClientException ex) {
        throw new CloudException(
                String.format("Error fetching expiring url for bucket %s filename %s in region %s",
                        bucket, filename, region), ex);
    }
}
项目:s3proxy    文件:AwsSdkTest.java   
@Test
public void testAwsV2UrlSigning() throws Exception {
    client = AmazonS3ClientBuilder.standard()
            .withClientConfiguration(V2_SIGNER_CONFIG)
            .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
            .withEndpointConfiguration(s3EndpointConfig)
            .build();

    String blobName = "foo";
    ObjectMetadata metadata = new ObjectMetadata();
    metadata.setContentLength(BYTE_SOURCE.size());
    client.putObject(containerName, blobName, BYTE_SOURCE.openStream(),
            metadata);

    Date expiration = new Date(System.currentTimeMillis() +
            TimeUnit.HOURS.toMillis(1));
    URL url = client.generatePresignedUrl(containerName, blobName,
            expiration, HttpMethod.GET);
    try (InputStream actual = url.openStream();
            InputStream expected = BYTE_SOURCE.openStream()) {
        assertThat(actual).hasContentEqualTo(expected);
    }
}
项目:s3proxy    文件:AwsSdkTest.java   
@Test
public void testAwsV4UrlSigning() throws Exception {
    String blobName = "foo";
    ObjectMetadata metadata = new ObjectMetadata();
    metadata.setContentLength(BYTE_SOURCE.size());
    client.putObject(containerName, blobName, BYTE_SOURCE.openStream(),
            metadata);

    Date expiration = new Date(System.currentTimeMillis() +
            TimeUnit.HOURS.toMillis(1));
    URL url = client.generatePresignedUrl(containerName, blobName,
            expiration, HttpMethod.GET);
    try (InputStream actual = url.openStream();
            InputStream expected = BYTE_SOURCE.openStream()) {
        assertThat(actual).hasContentEqualTo(expected);
    }
}
项目:detective    文件:HttpClientTask.java   
/**
 * Create a Commons HttpMethodBase object for the given HTTP method and URI specification.
 * @param httpMethod the HTTP method
 * @param uri the URI
 * @return the Commons HttpMethodBase object
 */
protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) {
  switch (httpMethod) {
    case GET:
      return new HttpGet(uri);
    case DELETE:
      return new HttpDeleteWithBody(uri);
    case HEAD:
      return new HttpHead(uri);
    case OPTIONS:
      return new HttpOptions(uri);
    case POST:
      return new HttpPost(uri);
    case PUT:
      return new HttpPut(uri);
    case TRACE:
      return new HttpTrace(uri);
    case PATCH:
      return new HttpPatch(uri);
    default:
      throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
  }
}
项目:CrypDist    文件:ServerAccessor.java   
public URL getURL(String fileName)
{
    log.debug("Generating pre-signed URL.");
    java.util.Date expiration = new java.util.Date();
    long milliSeconds = expiration.getTime();
    milliSeconds += Config.UPLOAD_EXPIRATION_TIME; // Add 10 sec.
    expiration.setTime(milliSeconds);

    GeneratePresignedUrlRequest generatePresignedUrlRequest =
            new GeneratePresignedUrlRequest(bucketName, fileName);
    generatePresignedUrlRequest.setMethod(HttpMethod.PUT);
    generatePresignedUrlRequest.setExpiration(expiration);

    return s3client.generatePresignedUrl(generatePresignedUrlRequest);
}
项目:aws-photosharing-example    文件:ContentHelper.java   
public URL getSignedUrl(String p_s3_bucket, String p_s3_file, Date p_exires) {         

    GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(p_s3_bucket, p_s3_file);
generatePresignedUrlRequest.setMethod(HttpMethod.GET); // Default.
generatePresignedUrlRequest.setExpiration(p_exires);

return s3Client.generatePresignedUrl(generatePresignedUrlRequest); 
  }
项目:ibm-cos-sdk-java    文件:AbstractAmazonS3.java   
@Override
public URL generatePresignedUrl(String bucketName, String key,
        Date expiration, HttpMethod method) throws SdkClientException {
    GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucketName, key, method);
    request.setExpiration(expiration);

    return generatePresignedUrl(request);
}
项目:ibm-cos-sdk-java    文件:AmazonS3Client.java   
@Override
public URL generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod method)
        throws SdkClientException {
    GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucketName, key, method);
    request.setExpiration(expiration);

    return generatePresignedUrl(request);
}
项目:ibm-cos-sdk-java    文件:AmazonS3Client.java   
/**
 * Pre-signs the specified request, using a signature query-string
 * parameter.
 *
 * @param request
 *            The request to sign.
 * @param methodName
 *            The HTTP method (GET, PUT, DELETE, HEAD) for the specified
 *            request.
 * @param bucketName
 *            The name of the bucket involved in the request. If the request
 *            is not an operation on a bucket this parameter should be null.
 * @param key
 *            The object key involved in the request. If the request is not
 *            an operation on an object, this parameter should be null.
 * @param expiration
 *            The time at which the signed request is no longer valid, and
 *            will stop working.
 * @param subResource
 *            The optional sub-resource being requested as part of the
 *            request (e.g. "location", "acl", "logging", or "torrent").
 */
protected <T> void presignRequest(Request<T> request, HttpMethod methodName,
        String bucketName, String key, Date expiration, String subResource) {
    // Run any additional request handlers if present
    beforeRequest(request);

    String resourcePath = "/" +
        ((bucketName != null) ? bucketName + "/" : "") +
        ((key != null) ? SdkHttpUtils.urlEncode(key, true) : "") +
        ((subResource != null) ? "?" + subResource : "");

    // Make sure the resource-path for signing does not contain
    // any consecutive "/"s.
    // Note that we should also follow the same rule to escape
    // consecutive "/"s when generating the presigned URL.
    // See ServiceUtils#convertRequestToUrl(...)
    resourcePath = resourcePath.replaceAll("(?<=/)/", "%2F");

    new S3QueryStringSigner(methodName.toString(), resourcePath, expiration)
        .sign(request, CredentialUtils.getCredentialsProvider(request.getOriginalRequest(), awsCredentialsProvider).getCredentials());

    // The Amazon S3 DevPay token header is a special exception and can be safely moved
    // from the request's headers into the query string to ensure that it travels along
    // with the pre-signed URL when it's sent back to Amazon S3.
    if (request.getHeaders().containsKey(Headers.SECURITY_TOKEN)) {
        String value = request.getHeaders().get(Headers.SECURITY_TOKEN);
        request.addParameter(Headers.SECURITY_TOKEN, value);
        request.getHeaders().remove(Headers.SECURITY_TOKEN);
    }
}
项目:stallion-core    文件:S3StorageService.java   
public String getSignedUploadUrl(String bucket, String fileKey, String contentType, Map headers) {
    GeneratePresignedUrlRequest req = new GeneratePresignedUrlRequest(bucket, fileKey);
    if (!empty(contentType)) {
        req.setContentType(contentType);
    }
    if  (headers != null) {
        for (Object key: headers.keySet())
        req.addRequestParameter(key.toString(), headers.get(key).toString());
    }
    req.setExpiration(Date.from(utcNow().plusDays(2).toInstant()));
    req.setMethod(HttpMethod.PUT);
    return client.generatePresignedUrl(req).toString();
}
项目:ecs-samples    文件:_07_PresignedURL.java   
public static void main(String[] args) throws Exception {
    // create the AWS S3 Client
    AmazonS3 s3 = AWSS3Factory.getS3Client();

    // retrieve the key value from user
    System.out.println( "Enter the object key:" );
    String key = new BufferedReader( new InputStreamReader( System.in ) ).readLine();

    // retrieve the expiration time for the object from user
    System.out.print( "How many hours should this tag be valid? " );
    String hours = new BufferedReader( new InputStreamReader( System.in ) ).readLine();

    // convert hours to a date
    Date expiration = new Date();
    long curTime_msec = expiration.getTime();
    long nHours = Long.valueOf(hours);
    curTime_msec += 60 * 60 * 1000 * nHours;
    expiration.setTime(curTime_msec); 

    // generate the object's pre-signed URL
    GeneratePresignedUrlRequest presignedUrl = new GeneratePresignedUrlRequest(AWSS3Factory.S3_BUCKET, key);
    presignedUrl.setMethod(HttpMethod.GET);
    presignedUrl.setExpiration(expiration);

    URL url = s3.generatePresignedUrl(presignedUrl);

    // print object's pre-signed URL
    System.out.println( String.format("object [%s/%s] pre-signed URL: [%s]",
            AWSS3Factory.S3_BUCKET, key, url.toString()));
}
项目:herd    文件:S3DaoImpl.java   
@Override
public String generateGetObjectPresignedUrl(String bucketName, String key, Date expiration, S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto)
{
    GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, key, HttpMethod.GET);
    generatePresignedUrlRequest.setExpiration(expiration);
    AmazonS3Client s3 = getAmazonS3(s3FileTransferRequestParamsDto);
    try
    {
        return s3Operations.generatePresignedUrl(generatePresignedUrlRequest, s3).toString();
    }
    finally
    {
        s3.shutdown();
    }
}
项目:digdag    文件:S3Storage.java   
@Override
public Optional<DirectUploadHandle> getDirectUploadHandle(String key)
{
    GeneratePresignedUrlRequest req = new GeneratePresignedUrlRequest(bucket, key);
    req.setMethod(HttpMethod.PUT);
    req.setExpiration(Date.from(Instant.now().plusSeconds(10*60)));

    String url = client.generatePresignedUrl(req).toString();

    return Optional.of(DirectUploadHandle.of(url));
}
项目:Cheddar    文件:S3FileStoreTest.java   
@Test
public void shouldGetURL() throws IOException {
    // Given
    final S3FileStore s3FileStore = new S3FileStore(bucketSchema);
    s3FileStore.initialize(mockAmazonS3Client);
    final int randomMillis = Randoms.randomInt(1000);
    DateTimeUtils.setCurrentMillisFixed(randomMillis);

    // When
    s3FileStore.publicUrlForFilePath(filePath);

    // Then
    verify(mockAmazonS3Client).generatePresignedUrl(bucketSchema + "-" + filePath.directory(), filePath.filename(),
            new Date(3600000 + randomMillis), HttpMethod.GET);
}
项目:amazon-cloudengine    文件:S3Service.java   
public static URL put(String key, File movie){
    try{
        System.out.println("Uploading a new object to S3 from a file\n");
           s3.putObject(new PutObjectRequest(bucketName, key, movie));

           System.out.println("Generating pre-signed URL.");
        java.util.Date expiration = new java.util.Date();
        long milliSeconds = expiration.getTime();
        milliSeconds += 1000 * 60 * 60 * 24 * 7; // Add 7 days.
        expiration.setTime(milliSeconds);

        GeneratePresignedUrlRequest generatePresignedUrlRequest = 
                new GeneratePresignedUrlRequest(bucketName, key);
        generatePresignedUrlRequest.setMethod(HttpMethod.GET); 
        generatePresignedUrlRequest.setExpiration(expiration);

        return s3.generatePresignedUrl(generatePresignedUrlRequest); 


    }catch (AmazonServiceException ase) {
           System.out.println("Caught an AmazonServiceException, which means your request made it "
                   + "to Amazon S3, but was rejected with an error response for some reason.");
           System.out.println("Error Message:    " + ase.getMessage());
           System.out.println("HTTP Status Code: " + ase.getStatusCode());
           System.out.println("AWS Error Code:   " + ase.getErrorCode());
           System.out.println("Error Type:       " + ase.getErrorType());
           System.out.println("Request ID:       " + ase.getRequestId());
       } catch (AmazonClientException ace) {
           System.out.println("Caught an AmazonClientException, which means the client encountered "
                   + "a serious internal problem while trying to communicate with S3, "
                   + "such as not being able to access the network.");
           System.out.println("Error Message: " + ace.getMessage());
       }

    return null;
}
项目:amazon-kinesis-aggregators    文件:ConfigFileUtils.java   
public static final String makeConfigFileURL(String configUrl) throws Exception {
    String url = null;

    if (configUrl.startsWith("http")) {
        url = configUrl;
    } else if (configUrl.startsWith("s3")) {
        AmazonS3 s3Client = new AmazonS3Client();
        String bucket = configUrl.split("/")[2];
        String prefix = configUrl.substring(configUrl.indexOf(bucket) + bucket.length() + 1);

        // generate a presigned url for X hours
        Date expiration = new Date();
        long msec = expiration.getTime();
        msec += 1000 * 60 * 60; // 1 hour.
        expiration.setTime(msec);

        GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(
                bucket, prefix);
        generatePresignedUrlRequest.setMethod(HttpMethod.GET);
        generatePresignedUrlRequest.setExpiration(expiration);

        URL s3url = s3Client.generatePresignedUrl(generatePresignedUrlRequest);
        url = s3url.toString();
    } else {
        url = new URL(String.format("file://%s", configUrl)).toString();
    }

    return url;
}
项目:AuthenticatedS3URLs    文件:SigningWorker.java   
protected WorkOrderResult generate(AmazonS3 s3Conn, AuthLinkSpec spec, Date ttl) {      
    GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(spec.getTarget().getBucketName(), spec.getTarget().getObjectName());
    generatePresignedUrlRequest.setMethod(HttpMethod.GET); 
    generatePresignedUrlRequest.setExpiration(ttl);


    URL url =null;
    WorkOrderResult woResult=new WorkOrderResult(spec);

    // If WorkOrder contains an https request, generate that
    if(spec.getProtocol().isHttps()) {
        // Set HTTPS protocol URL by accessing the s3 https endpoint
        s3Conn.setEndpoint(HTTPS_ENDPOINT_);
        url = s3Conn.generatePresignedUrl(generatePresignedUrlRequest);
        woResult.getSignedHttpsUrl().setUrl(url.toString());
        //woResult.getSignedHttpsUrl().setProtocol(HTTPS_);
        if(spec.getProcessing().isValidateAuthURL() == true) {
            if(validTarget(url)) {
                woResult.getSignedHttpsUrl().setValid(true);
            }
        }
    }

    // If WorkOrder contains an http request, generate that
    if(spec.getProtocol().isHttp()) {
        // Set HTTP protocol URL by accessing the s3 http endpoint
        s3Conn.setEndpoint(HTTP_ENDPOINT_);
        url = s3Conn.generatePresignedUrl(generatePresignedUrlRequest);
        woResult.getSignedHttpUrl().setUrl(url.toString());
        //woResult.getSignedHttpUrl().setProtocol(HTTP_);
        if(spec.getProcessing().isValidateAuthURL() == true) {
            if(validTarget(url)) {
                woResult.getSignedHttpUrl().setValid(true);
            }
        }
    }

    return(woResult);
}
项目:cloudExplorer    文件:Acl.java   
String setACLurl(String object, String access_key, String secret_key, String endpoint, String bucket) {
    String URL = null;
    try {
        AWSCredentials credentials = new BasicAWSCredentials(access_key, secret_key);
        AmazonS3 s3Client = new AmazonS3Client(credentials,
                new ClientConfiguration());
         if (endpoint.contains("amazonaws.com")) {
            String aws_endpoint = s3Client.getBucketLocation(new GetBucketLocationRequest(bucket));
            if (aws_endpoint.contains("US")) {
                s3Client.setEndpoint("https://s3.amazonaws.com");
            } else if (aws_endpoint.contains("us-west")) {
                s3Client.setEndpoint("https://s3-" + aws_endpoint + ".amazonaws.com");
            } else if (aws_endpoint.contains("eu-west")) {
                s3Client.setEndpoint("https://s3-" + aws_endpoint + ".amazonaws.com");
            } else if (aws_endpoint.contains("ap-")) {
                s3Client.setEndpoint("https://s3-" + aws_endpoint + ".amazonaws.com");
            } else if (aws_endpoint.contains("sa-east-1")) {
                s3Client.setEndpoint("https://s3-" + aws_endpoint + ".amazonaws.com");
            } else {
                s3Client.setEndpoint("https://s3." + aws_endpoint + ".amazonaws.com");
            }
        } else {
            s3Client.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).build());
            s3Client.setEndpoint(endpoint);
        }
        java.util.Date expiration = new java.util.Date();
        long milliSeconds = expiration.getTime();
        milliSeconds += 1000 * 60 * 1000; // Add 1 hour.
        expiration.setTime(milliSeconds);
        GeneratePresignedUrlRequest generatePresignedUrlRequest
                = new GeneratePresignedUrlRequest(bucket, object);
        generatePresignedUrlRequest.setMethod(HttpMethod.GET);
        generatePresignedUrlRequest.setExpiration(expiration);
        URL url = s3Client.generatePresignedUrl(generatePresignedUrlRequest);
        URL = ("Pre-Signed URL = " + url.toString());
        StringSelection stringSelection = new StringSelection(url.toString());
    } catch (Exception setACLpublic) {
    }
    return URL;
}
项目:elasticsearch_my    文件:AmazonS3Wrapper.java   
@Override
public URL generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod method) throws AmazonClientException {
    return delegate.generatePresignedUrl(bucketName, key, expiration, method);
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public URL generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod method) throws AmazonClientException {
    throw new UnsupportedOperationException();
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public URL generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod method) throws AmazonClientException {
    throw new UnsupportedOperationException();
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public URL generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod method) throws AmazonClientException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public URL generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod method) throws AmazonClientException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public URL generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod method) throws AmazonClientException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public URL generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod method) throws AmazonClientException {
    throw new UnsupportedOperationException();
}
项目:ibm-cos-sdk-java    文件:AbstractAmazonS3.java   
@Override
public URL generatePresignedUrl(String bucketName, String key,
        Date expiration) throws SdkClientException {
    return generatePresignedUrl(bucketName, key, expiration, HttpMethod.GET);
}
项目:ibm-cos-sdk-java    文件:AmazonS3Client.java   
@Override
public URL generatePresignedUrl(String bucketName, String key, Date expiration)
        throws SdkClientException {
    return generatePresignedUrl(bucketName, key, expiration, HttpMethod.GET);
}
项目:S3Decorators    文件:S3Decorator.java   
@Override
public URL generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod method) throws SdkClientException {
  return call(() -> getDelegate().generatePresignedUrl(bucketName, key, expiration, method));
}
项目:stallion-core    文件:S3StorageService.java   
public String getSignedDownloadUrl(String bucket, String fileKey) {
    GeneratePresignedUrlRequest req = new GeneratePresignedUrlRequest(bucket, fileKey);
    req.setExpiration(Date.from(utcNow().plusMinutes(60).toInstant()));
    req.setMethod(HttpMethod.GET);
    return client.generatePresignedUrl(req).toString();
}
项目:teamcity-s3-artifact-storage-plugin    文件:S3PreSignedUrlProvider.java   
@NotNull
String getPreSignedUrl(@NotNull HttpMethod httpMethod, @NotNull String bucketName, @NotNull String objectKey, @NotNull Map<String, String> params) throws IOException;
项目:georocket    文件:S3Store.java   
@Override
protected void doAddChunk(String chunk, String path, Handler<AsyncResult<String>> handler) {
  if (path == null || path.isEmpty()) {
    path = "/";
  }

  // generate new file name
  String id = generateChunkId();
  String filename = PathUtils.join(path, id);
  String key = PathUtils.removeLeadingSlash(filename);

  vertx.<URL>executeBlocking(f -> {
    f.complete(generatePresignedUrl(key, HttpMethod.PUT));
  }, ar -> {
    if (ar.failed()) {
      handler.handle(Future.failedFuture(ar.cause()));
      return;
    }

    URL u = ar.result();
    log.debug("PUT " + u);

    Buffer chunkBuf = Buffer.buffer(chunk);
    HttpClientRequest request = client.put(u.getFile());

    request.putHeader("Host", u.getHost());
    request.putHeader("Content-Length", String.valueOf(chunkBuf.length()));

    request.exceptionHandler(t -> {
      handler.handle(Future.failedFuture(t));
    });

    request.handler(response -> {
      Buffer errorBody = Buffer.buffer();
      if (response.statusCode() != 200) {
        response.handler(buf -> {
          errorBody.appendBuffer(buf);
        });
      }
      response.endHandler(v -> {
        if (response.statusCode() == 200) {
          handler.handle(Future.succeededFuture(filename));
        } else {
          log.error(errorBody);
          handler.handle(Future.failedFuture(response.statusMessage()));
        }
      });
    });

    request.end(chunkBuf);
  });
}
项目:georocket    文件:S3Store.java   
@Override
public void getOne(String path, Handler<AsyncResult<ChunkReadStream>> handler) {
  String key = PathUtils.removeLeadingSlash(PathUtils.normalize(path));
  vertx.<URL>executeBlocking(f -> {
    f.complete(generatePresignedUrl(key, HttpMethod.GET));
  }, ar -> {
    if (ar.failed()) {
      handler.handle(Future.failedFuture(ar.cause()));
      return;
    }

    URL u = ar.result();
    log.debug("GET " + u);

    HttpClientRequest request = client.get(ar.result().getFile());
    request.putHeader("Host", u.getHost());

    request.exceptionHandler(t -> {
      handler.handle(Future.failedFuture(t));
    });

    request.handler(response -> {
      if (response.statusCode() == 200) {
        String contentLength = response.getHeader("Content-Length");
        long chunkSize = Long.parseLong(contentLength);
        handler.handle(Future.succeededFuture(new DelegateChunkReadStream(chunkSize, response)));
      } else {
        Buffer errorBody = Buffer.buffer();
        response.handler(buf -> {
          errorBody.appendBuffer(buf);
        });
        response.endHandler(v -> {
          log.error(errorBody);
          handler.handle(Future.failedFuture(response.statusMessage()));
        });
      }
    });

    request.end();
  });
}
项目:georocket    文件:S3Store.java   
@Override
protected void doDeleteChunks(Queue<String> paths, Handler<AsyncResult<Void>> handler) {
  if (paths.isEmpty()) {
    handler.handle(Future.succeededFuture());
    return;
  }

  String key = PathUtils.removeLeadingSlash(PathUtils.normalize(paths.poll()));
  vertx.<URL>executeBlocking(f -> {
    f.complete(generatePresignedUrl(key, HttpMethod.DELETE));
  }, ar -> {
    if (ar.failed()) {
      handler.handle(Future.failedFuture(ar.cause()));
      return;
    }

    URL u = ar.result();
    log.debug("DELETE " + u);

    HttpClientRequest request = client.delete(ar.result().getFile());
    request.putHeader("Host", u.getHost());

    request.exceptionHandler(t -> {
      handler.handle(Future.failedFuture(t));
    });

    request.handler(response -> {
      Buffer errorBody = Buffer.buffer();
      if (response.statusCode() != 204) {
        response.handler(buf -> {
          errorBody.appendBuffer(buf);
        });
      }
      response.endHandler(v -> {
        switch (response.statusCode()) {
          case 204:
          case 404:
            doDeleteChunks(paths, handler);
            break;
          default:
            log.error(errorBody);
            handler.handle(Future.failedFuture(response.statusMessage()));
        }
      });
    });

    request.end();
  });
}
项目:Camel    文件:AmazonS3ClientMock.java   
@Override
public URL generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod method) throws AmazonClientException {
    throw new UnsupportedOperationException();
}
项目:presto    文件:MockAmazonS3.java   
@Override
public URL generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod method)
        throws AmazonClientException
{
    return null;
}
项目:daikon    文件:AmazonS3TestWrapper.java   
@Override
public URL generatePresignedUrl(String bucketName, String key, Date expiration, HttpMethod method) throws AmazonClientException {
    return delegate.generatePresignedUrl(bucketName, key, expiration, method);
}