I’m using 5$/m VPS (1 GB RAM) and run docker container with my Golang application.
I have REST API endpoint to upload an image (limited to 5mb), which I upload to Spaces straight forward.
The problem is that it works fine with small images, like 50-100 kb, but when I try to upload 650kb image, I receive following error: multipart: NextPart: bufio: buffer full
The code that handles uploading:
// Limit Upload File Size
c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, MAX_UPLOAD_SIZE)
fileHeader, err := c.FormFile("file")
if err != nil {
c.JSON(http.StatusBadRequest, &uploadResponse{
Status: "error",
Msg: err.Error(),
})
return
}
file, err := fileHeader.Open() // IT BREAKS HERE
if err != nil {
c.JSON(http.StatusBadRequest, &uploadResponse{
Status: "error",
Msg: err.Error(),
})
return
}
defer file.Close()
Have you any ideas what can go wrong?
P.S. I mock Spaces localy with localstack’s S3, and all images works just fine. But this same images cause this problem on my VPS.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.