S3/CloudFront problem while trying to fetch gziped files using XMLHttpRequest with Range headers

0

Hello,

I am trying to configure an S3 bucket and a CloudFront distribution that points to that bucket to allow to download large binary files in parts (with gzip compression) using the GET Range header. So far without success:

      let request = new XMLHttpRequest();
      request.open("GET", path, true);
      request.setRequestHeader("Range", `bytes=${startByte}-${endByte}`);
      request.responseType = "arraybuffer"; // or 'blob';   
      request.send();

In S3, each binary file has the following metadata:

Content-Encoding: gzip Content-Type: binary/octet-stream

S3 CORS configuration is as follows:

[ { "AllowedHeaders": [ "" ], "AllowedMethods": [ "GET", "HEAD" ], "AllowedOrigins": [ "" ], "ExposeHeaders": [] } ]

Files can be downloaded correctly without the Range header.

When using the range header xmlhttp.onerror = (e) => {} is triggered. In the Chrome network debugging section I see "net::ERROR_CONTENT_DECODING_FAILED."

Any ideas how to solve this?

1개 답변
0

Could it be that the part is too large? Use range requests to cache large objects

profile pictureAWS
전문가
kentrad
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인