【问题标题】:Is there a way to get an s3 object stream chunk by chunk using AWSSDK in dotnet?有没有办法在dotnet中使用AWSSDK逐块获取s3对象流?
【发布时间】:2022-01-27 04:52:36
【问题描述】:

当一个新对象被 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 });

【问题讨论】:

    标签: .net amazon-web-services amazon-s3 stream


    【解决方案1】:

    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
    

    【讨论】:

    • 有意思,我去看看。谢谢。
    猜你喜欢
    • 2014-06-04
    • 2022-01-07
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 2019-09-26
    • 2014-05-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多