Skip to content

Commit

Permalink
fix: Fixing chunk upload by adding leading int
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Jul 21, 2022
1 parent fafd3c2 commit 086dfcc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/crud/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"mime/multipart"
"net/http"
"strconv"
"strings"

"github.com/ViBiOh/fibr/pkg/provider"
Expand Down Expand Up @@ -99,6 +100,13 @@ func (a App) handleMultipart(w http.ResponseWriter, r *http.Request, request pro

if len(r.Header.Get("X-Chunk-Upload")) != 0 {
if chunkNumber := r.Header.Get("X-Chunk-Number"); len(chunkNumber) != 0 {
chunkNumberValue, err := strconv.ParseUint(chunkNumber, 10, 64)
if err != nil {
a.error(w, r, request, model.WrapInvalid(fmt.Errorf("unable to parse chunk number: %s", err)))
}

chunkNumber = fmt.Sprintf("%10d", chunkNumberValue)

a.uploadChunk(w, r, request, values["filename"], chunkNumber, file)
} else {
a.mergeChunk(w, r, request, values)
Expand Down

0 comments on commit 086dfcc

Please sign in to comment.