Skip to content

Commit

Permalink
Fix error with AWS SDK V2
Browse files Browse the repository at this point in the history
passing a read closer seems to mess with SDK V2, for now, read body in memory

Signed-off-by: Sid Sun <sid@sidsun.com>
  • Loading branch information
Sid-Sun committed Nov 25, 2022
1 parent b339cdd commit 83c8f53
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
"encoding/base64"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"

"github.com/sid-sun/ioctl-api/config"
"github.com/sid-sun/ioctl-api/src/model"
Expand Down Expand Up @@ -93,7 +95,14 @@ func (s *serviceImpl) CreateE2ESnippet(snippet io.Reader, snippetID string, ephe
if !ephemeral {
st = types.ProlongedSnippet
}
err := s.sc.NewSnippet(snippet, snippetID, st)
d, err := ioutil.ReadAll(snippet)
if err != nil {
return err
}
if len(d) == 0 {
return errors.New("body cannot be empty")
}
err = s.sc.NewSnippet(bytes.NewReader(d), snippetID, st)
if err != nil {
if err != model.ErrAlreadyExists {
utils.Logger.Error(fmt.Sprintf("%s : %v", "[Service] [CreateSnippet] [NewE2ESnippet]", err))
Expand Down

0 comments on commit 83c8f53

Please sign in to comment.