Open
Description
Hi,
I want to use body from output of s3.Client.GetObject
as body of LambdaFunctionURLStreamingResponse
.
However, out.Body
is io.ReadCloser
, while LambdaFunctionURLStreamingResponse.Body
is io.Reader
.
I know that io.ReadCloser is compatible with io.Reader, but this would leave out.Body without being close.
How can I use body from output of s3 GetObject as body of LambdaFunctionURLStreamingResponse?
Below is the simplify version of my code
func handler(
ctx context.Context,
req events.LambdaFunctionURLRequest,
) (res *events.LambdaFunctionURLStreamingResponse, err error) {
var s3Client *s3.Client
// ...
out, err := s3Client.GetObject(context.TODO(), &s3.GetObjectInput{
Bucket: &bucket,
Key: &key,
})
if err != nil {
return nil, err
}
resp := &events.LambdaFunctionURLStreamingResponse{
StatusCode: http.StatusOK,
Headers: map[string]string{"Content-Type": "application/x-ndjson"},
}
// What is the secure way to do this ?
resp.Body = out.Body
return resp, nil
}
Metadata
Metadata
Assignees
Labels
No labels