1

I'm creating a simple application where it allows users to upload big files using simple-uploader since this plugin sends the files in chunks instead of one big file. The problem is that when I save the file the first chunk is the only one that is being saved. Is there a way in Go where I'll wait for all the chunks to arrive in the server then save it afterward?

Here's a snippet of the code I'm doing:

    dFile, err := c.FormFile("file")
    if err != nil {
        return SendError(c, err)
    }

    filename := dFile.Filename
    f, err := dFile.Open()

    if err != nil {
        return SendError(c, err)
    }
    defer f.Close()

    // save file in s3
    duration := sss.UploadFile(f, "temp/"+filename")
    ... send response

By the way for this project, I'm using the fiber framework.

3
  • To be honest, I had no idea. Here is what I found on the topic so far: stackoverflow.com/questions/40684307/…, but that's what you are already doing, right? Commented Dec 25, 2020 at 15:49
  • Did you also use the ParseMultiPartForm function of http.Request? Commented Dec 25, 2020 at 15:53
  • do you mean you have used this github.com/simple-uploader/Uploader ? Commented Dec 25, 2020 at 16:40

1 Answer 1

0

While working on this I encountered tus-js-client which is doing the same as the simple-uploader and implementation in go called tusd which will reassemble the chunks so you don't have to worry about it anymore.

Here's a discussion where I posted my solution: https://stackoverflow.com/a/65785097/549529.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.