Update
All checks were successful
Build & Deploy PLDpro.Web Test to 192.168.1.100 / build-and-deploy (push) Successful in 1m13s
All checks were successful
Build & Deploy PLDpro.Web Test to 192.168.1.100 / build-and-deploy (push) Successful in 1m13s
This commit is contained in:
@@ -33,9 +33,11 @@ public sealed class S3StorageService(IAmazonS3 s3) : IStorageService
|
||||
BucketName = bucket,
|
||||
ContinuationToken = token
|
||||
}, ct);
|
||||
|
||||
items.AddRange(resp.S3Objects.Select(o => new ObjectItem(o.Key, o.Size, o.LastModified)));
|
||||
token = (bool)resp.IsTruncated ? resp.NextContinuationToken : null;
|
||||
if (resp.S3Objects != null)
|
||||
{
|
||||
items.AddRange(resp.S3Objects.Select(o => new ObjectItem(o.Key, o.Size, o.LastModified)));
|
||||
token = (bool)resp.IsTruncated ? resp.NextContinuationToken : null;
|
||||
}
|
||||
} while (token is not null);
|
||||
|
||||
return items;
|
||||
@@ -52,4 +54,24 @@ public sealed class S3StorageService(IAmazonS3 s3) : IStorageService
|
||||
};
|
||||
await _s3.PutObjectAsync(req, ct);
|
||||
}
|
||||
|
||||
|
||||
public async Task<(Stream Stream, string ContentType, long? ContentLength)> GetObjectAsync(
|
||||
string bucket, string key, CancellationToken ct = default)
|
||||
{
|
||||
var resp = await _s3.GetObjectAsync(new GetObjectRequest
|
||||
{
|
||||
BucketName = bucket,
|
||||
Key = key
|
||||
}, ct);
|
||||
|
||||
// ResponseStream NICHT kopieren, sondern direkt zurückgeben (Server streamt es weiter)
|
||||
var contentType = string.IsNullOrWhiteSpace(resp.Headers.ContentType)
|
||||
? "application/octet-stream"
|
||||
: resp.Headers.ContentType;
|
||||
|
||||
long? len = resp.Headers.ContentLength >= 0 ? resp.Headers.ContentLength : null;
|
||||
return (resp.ResponseStream, contentType, len);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user