File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -109,10 +109,21 @@ func (h *Handler) WriteSQS(ctx context.Context, r io.Reader) error {
109109 key = strings .Trim (h .DestinationURI .Path , "/" ) + "/" + key
110110 }
111111
112+ // Read the entire content into memory to create a seekable reader
113+ // This allows AWS SDK to retry S3 PutObject operations by rewinding the stream
114+ var body io.ReadSeeker
115+ if r != nil {
116+ data , err := io .ReadAll (r )
117+ if err != nil {
118+ return fmt .Errorf ("failed to read message data: %w" , err )
119+ }
120+ body = bytes .NewReader (data )
121+ }
122+
112123 _ , err = h .S3Client .PutObject (ctx , & s3.PutObjectInput {
113124 Bucket : aws .String (h .DestinationURI .Host ),
114125 Key : & key ,
115- Body : r ,
126+ Body : body ,
116127 ContentType : aws .String ("application/x-aws-sqs" ),
117128 })
118129 if err != nil {
You can’t perform that action at this time.
0 commit comments