有没有办法在 dotnet 中使用 AWSSDK 逐块获取 s3 对象流?

Is there a way to get an s3 object stream chunk by chunk using AWSSDK in dotnet?

我们有一个系统可以在 PUT 新对象时从 AWS S3 获取事件。

我们注册了一堆服务,我们将 GetObjectResponse 传递给这些服务。每个服务通过 ResponseStream 检查 GetObjectResponse。如果一个对象在处理该对象时“通过”,它将转到下一个对象,依此类推。但是,一旦ResponseStream开始被一个服务读取,Position就不能设置为0。

因此,GetObjectResponse 为每个服务刷新以检查它。然后,一旦找到服务,就得重新刷新。

有什么方法可以防止多次调用 GetObjectAsync

我们使用以下方法获取对象:

var s3 = this.GetProvider().GetRequiredService<IAmazonS3>();
using GetObjectResponse getObjectResponse = await s3.GetObjectAsync(new GetObjectRequest() { BucketName = bucketName, Key = objectKey });

S3 提供了一个名为 byte-range fetches 的功能,它允许我们通过块方法从 s3 中提取大文件。

var s3 = this.GetProvider().GetRequiredService<IAmazonS3>();
using GetObjectResponse getObjectResponse = await s3.GetObjectAsync(new GetObjectRequest() { BucketName = bucketName, Key = objectKey, Range='bytes=START_BYTE_ID-END_BYTE_ID' }); #Place your values in