How to set Amazon S3 bucket presigned URL expiration time in 1 year from current date

 

Questions


Images are uploaded to an Amazon S3 bucket. I need to get a presigned URL from Amazon server. Also I want to set the expiry time of that URL. That can take only maximum of 17 days. But I can’t set maximum of 1 year expiration time.

      Calendar cal = Calendar.getInstance();
        cal.add(Calendar.YEAR, 1);
        Date nextYear = cal.getTime();

    GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(
                "bucketName", "accessname");
        generatePresignedUrlRequest.setMethod(HttpMethod.GET);
        generatePresignedUrlRequest
                .setExpiration(nextYear);
        URL url = s3client
                .generatePresignedUrl(generatePresignedUrlRequest);
        bucketURL = url.toString();

 

 

————————————————-

Answer

amazon-s3,amazon-web-services,java

Facebook Comments

Post a comment