I'm having issues generating the pre-signed URL and attempting to download an object. For files larger than 190 MB, for example video file (such as a video file, which is the specific issue at the momen), the request fails, and the content simply isn't retrieved. When I try to fetch the object from the bucket to download, the URL is generated, but it doesn't work as expected.
My bucket already has CORS configured. When I try to download or even generate the pre-signed URL directly from the bucket, the bucket itself doesn’t return anything. I can’t view the specific video, but I am able to generate the download.
Java implementation:
/* Create a pre-signed URL to download an object in a subsequent GET request. */
public String createPresignedGetUrl(String keyName) {
try (S3Presigner presigner = S3Presigner.create()) {
GetObjectRequest objectRequest = GetObjectRequest.builder()
.bucket(awsProperties.getBucketName())
.key(keyName)
.build();
GetObjectPresignRequest presignRequest = GetObjectPresignRequest.builder()
.signatureDuration(Duration.ofMinutes(5))
.getObjectRequest(objectRequest)
.build();
PresignedGetObjectRequest presignedRequest = presigner.presignGetObject(presignRequest);
log.info("URL pré-assinada: [{}]", presignedRequest.url().toString());
log.info("Método HTTP: [{}]", presignedRequest.httpRequest().method());
return presignedRequest.url().toExternalForm();
}
}
URL generated (this video is 439 MB in size.):
https://my-bucket.s3.region-re-1.amazonaws.com/directory%201/directory/Videos/directory/B%20-%20file%C3%A7%C3%A3o%201%20-%201%C2%BA%20file%20e%file-video.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20241028T104332Z&X-Amz-SignedHeaders=host&X-Amz-Expires=2400&X-Amz-Credential=AKIA4MQA3GRJHVQVCS4Q%2F20241028%2Fsa-east-1%2Fs3%2Faws4_request&X-Amz-Signature=c83bae7ca93b1937846af3b45f09454b3214a184464418cac74fa1c12da3bbe9