List of usage examples for com.amazonaws HttpMethod GET
HttpMethod GET
To view the source code for com.amazonaws HttpMethod GET.
Click Source Link
From source file:com.handywedge.binarystore.store.aws.BinaryStoreManagerImpl.java
License:MIT License
private URL getPresignedUrl(AmazonS3 s3client, String buckrtName, String key) { logger.info("getPresignedUrl start."); java.util.Date expiration = new java.util.Date(); long milliSeconds = expiration.getTime(); milliSeconds += Long.parseLong(PropertiesUtil.get("aws.presignedurl.expiration")); expiration.setTime(milliSeconds);/*ww w. jav a 2 s . co m*/ GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(buckrtName, key); generatePresignedUrlRequest.setMethod(HttpMethod.GET); generatePresignedUrlRequest.setExpiration(expiration); URL PresignedUrl = s3client.generatePresignedUrl(generatePresignedUrlRequest); logger.info("getPresignedUrl: end. url={}", PresignedUrl); return PresignedUrl; }
From source file:com.jeet.s3.AmazonS3ClientWrapper.java
License:Open Source License
public String generatePresignedURLForContent(String key) { try {// w ww . ja v a 2s . c om java.util.Date expiration = new java.util.Date(); long msec = expiration.getTime(); msec += 1000 * 60 * 60; // 1 hour. expiration.setTime(msec); GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest( Constants.BUCKET_NAME, key); generatePresignedUrlRequest.setMethod(HttpMethod.GET); // Default. generatePresignedUrlRequest.setExpiration(expiration); URL s = s3Client.generatePresignedUrl(generatePresignedUrlRequest); return s.toString(); } catch (Exception e) { e.printStackTrace(); } return ""; }
From source file:com.jeet.s3.AmazonS3ClientWrapper.java
License:Open Source License
public String generatePresignedURL(String key) { try {//from w w w . ja v a 2 s .co m GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest( Constants.BUCKET_NAME, key); generatePresignedUrlRequest.setMethod(HttpMethod.GET); // Default. URL s = s3Client.generatePresignedUrl(generatePresignedUrlRequest); return s.toString(); } catch (Exception e) { e.printStackTrace(); } return ""; }
From source file:de.taimos.pipeline.aws.S3PresignUrlStep.java
License:Apache License
@DataBoundConstructor public S3PresignUrlStep(String bucket, String key, String httpMethod, Integer durationInSeconds, boolean pathStyleAccessEnabled, boolean payloadSigningEnabled) { super(pathStyleAccessEnabled, payloadSigningEnabled); this.bucket = bucket; this.key = key; if (durationInSeconds == null) { this.durationInSeconds = 60; //60 seconds } else {/*from w w w . j av a 2 s. c o m*/ this.durationInSeconds = durationInSeconds; } if (httpMethod == null) { this.httpMethod = HttpMethod.GET; } else { this.httpMethod = HttpMethod.valueOf(httpMethod); } }
From source file:io.konig.camel.aws.s3.DeleteObjectProducer.java
License:Apache License
private void createDownloadLink(AmazonS3 s3Client, Exchange exchange) { String bucketName = exchange.getIn().getHeader(S3Constants.BUCKET_NAME, String.class); if (ObjectHelper.isEmpty(bucketName)) { bucketName = getConfiguration().getBucketName(); }/*from w w w.j a v a2s. com*/ if (bucketName == null) { throw new IllegalArgumentException("AWS S3 Bucket name header is missing."); } String key = exchange.getIn().getHeader(S3Constants.KEY, String.class); if (key == null) { throw new IllegalArgumentException("AWS S3 Key header is missing."); } Date expiration = new Date(); long milliSeconds = expiration.getTime(); Long expirationMillis = exchange.getIn().getHeader(S3Constants.DOWNLOAD_LINK_EXPIRATION, Long.class); if (expirationMillis != null) { milliSeconds += expirationMillis; } else { milliSeconds += 1000 * 60 * 60; // Default: Add 1 hour. } expiration.setTime(milliSeconds); GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, key); generatePresignedUrlRequest.setMethod(HttpMethod.GET); generatePresignedUrlRequest.setExpiration(expiration); URL url = s3Client.generatePresignedUrl(generatePresignedUrlRequest); Message message = getMessageForResponse(exchange); message.setHeader(S3Constants.DOWNLOAD_LINK, url.toString()); }
From source file:io.stallion.services.S3StorageService.java
License:Open Source License
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(); }
From source file:org.apache.flink.cloudsort.io.aws.AwsCurlInput.java
License:Apache License
@Override public void open(String objectName) throws IOException { Preconditions.checkNotNull(bucket);/* w w w .ja v a 2 s. c o m*/ AmazonS3 s3Client = new AmazonS3Client(new ProfileCredentialsProvider()); java.util.Date expiration = new java.util.Date(); long msec = expiration.getTime(); msec += 1000 * 60 * 60; // Add 1 hour. expiration.setTime(msec); GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucket, objectName); generatePresignedUrlRequest.setMethod(HttpMethod.GET); generatePresignedUrlRequest.setContentType(CONTENT_TYPE); generatePresignedUrlRequest.setExpiration(expiration); String url = s3Client.generatePresignedUrl(generatePresignedUrlRequest).toExternalForm(); downloader = new ProcessBuilder("curl", "-s", "-X", "GET", "-H", "Content-Type: " + CONTENT_TYPE, url) .redirectError(Redirect.INHERIT).start(); }
From source file:org.apache.usergrid.apm.service.AWSUtil.java
License:Apache License
public static String generatePresignedURLForCrashLog(String fullAppName, String fileName) { DeploymentConfig config = DeploymentConfig.geDeploymentConfig(); AWSCredentials credentials = new BasicAWSCredentials(config.getAccessKey(), config.getSecretKey()); AmazonS3Client client = new AmazonS3Client(credentials); String s3FullFileName = AWSUtil.formS3CrashFileUrl(fullAppName, fileName); GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(config.getS3LogBucket(), s3FullFileName, HttpMethod.GET); request.setExpiration(new Date(System.currentTimeMillis() + (120 * 60 * 1000))); //expires in 2 hour return client.generatePresignedUrl(request).toString(); }
From source file:org.apache.usergrid.apm.util.AwsS3Util.java
License:Apache License
public static String generatePresignedURL(String appId, String fileName) { DeploymentConfig config = DeploymentConfig.geDeploymentConfig(); AWSCredentials credentials = new BasicAWSCredentials(config.getAccessKey(), config.getSecretKey()); AmazonS3Client client = new AmazonS3Client(credentials); String env = config.getEnvironment(); String s3FullFileName = env + "/crashlog/" + appId + "/" + fileName; GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(config.getS3LogBucket(), s3FullFileName, HttpMethod.GET); request.setExpiration(new Date(System.currentTimeMillis() + (120 * 60 * 1000))); //expires in 2 hour return client.generatePresignedUrl(request).toString(); }
From source file:org.cloudifysource.esc.driver.provisioning.privateEc2.AmazonS3Uploader.java
License:Open Source License
/** * Returns a pre-signed URL for accessing an Amazon S3 resource. * /*from w w w . java 2 s. co m*/ * @param bucketName * The bucket where the resource lies. * @param objectKey * The key object. * @return A pre-signed URL for accessing an Amazon S3 resource. */ public String generatePresignedURL(final String bucketName, final String objectKey) { final Date expiration = new Date(); expiration.setTime(System.currentTimeMillis() + ONE_DAY_IN_MILLIS); final GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, objectKey); generatePresignedUrlRequest.setMethod(HttpMethod.GET); // Default. generatePresignedUrlRequest.setExpiration(expiration); URL generatePresignedObjectURL = s3client.generatePresignedUrl(generatePresignedUrlRequest); if (logger.isLoggable(Level.FINEST)) { logger.finest("Zip uploaded. Limited signed URL: " + generatePresignedObjectURL); } return generatePresignedObjectURL.toString(); }