Skip to content

Commit

Permalink
BUG/MAJOR: storage: don't clear the file on general file PUT
Browse files Browse the repository at this point in the history
  • Loading branch information
mjuraga committed Dec 13, 2024
1 parent fecffd4 commit bdac979
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions handlers/general_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package handlers
import (
"bufio"
"fmt"
"io"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -188,16 +189,10 @@ func (h *StorageReplaceStorageGeneralFileHandlerImpl) Handle(params storage.Repl
return storage.NewReplaceStorageGeneralFileDefault(int(*e.Code)).WithPayload(e)
}

file, ok := params.FileUpload.(*runtime.File)
if !ok {
data, err := io.ReadAll(params.FileUpload)
if err != nil {
return storage.NewReplaceStorageGeneralFileBadRequest()
}
data := []byte{}
if _, err := file.Read(data); err != nil {
e := misc.HandleError(err)
return storage.NewReplaceStorageGeneralFileDefault(int(*e.Code)).WithPayload(e)
}

_, err = gs.Replace(params.Name, string(data))
if err != nil {
e := misc.HandleError(err)
Expand Down

0 comments on commit bdac979

Please sign in to comment.