commit b6db4dacbb21a7251040b384ae08da5875d50e59
parent 566b5575e22ff213da50a245898981fee8e41c5a
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 31 Jan 2023 00:42:53 -0800
add metadata about the file upload
Diffstat:
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/cmd/dkfupload/main.go b/cmd/dkfupload/main.go
@@ -109,6 +109,8 @@ func main() {
body.Set("fileName", fs.Name())
body.Set("fileSize", strconv.FormatInt(fileSize, 10))
body.Set("fileSha256", fileSha256)
+ body.Set("chunkSize", strconv.FormatInt(maxChunkSize, 10))
+ body.Set("nbChunks", strconv.FormatInt(nbChunks, 10))
req, _ := http.NewRequest(http.MethodPost, baseUrl+"/file-drop/"+filedropUUID+"/tmp-init", strings.NewReader(body.Encode()))
req.Header.Set("User-Agent", userAgent)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -4388,7 +4388,9 @@ func FileDropTmpInitHandler(c echo.Context) error {
fileName := c.Request().PostFormValue("fileName")
fileSize := c.Request().PostFormValue("fileSize")
fileSha256 := c.Request().PostFormValue("fileSha256")
- data := []byte(fileName + "\n" + fileSize + "\n" + fileSha256 + "\n")
+ chunkSize := c.Request().PostFormValue("chunkSize")
+ nbChunks := c.Request().PostFormValue("nbChunks")
+ data := []byte(fileName + "\n" + fileSize + "\n" + fileSha256 + "\n" + chunkSize + "\n" + nbChunks + "\n")
if err := os.WriteFile(filepath.Join(config.Global.ProjectFiledropPath(), filedropUUID, "metadata"), data, 0644); err != nil {
logrus.Error(err)
return c.NoContent(http.StatusInternalServerError)