Post Form With Image

Hi,

I am making an image uploader in golang.
I am using req.ParseMulitpartForm at my server, But it is taking too much time.
For 3MB Image, req.ParseMulitpartForm is taking around 2.5 seconds to parse, I want to do it under 100ms.

Any suggestion why it is taking time. ?

start = time.Now()
r.ParseMulitpartForm(0)
file, handle, err := r.FormFile("IMAGE")
if err != nil {

}
defer file.Close()
elasped = time.Since(start)
fmt.Println(elasped.Seconds())

Well, where is the time being spent? I doubt the Go code itself takes that much time. What is your upload speed? The information and code you have given us so far is not enough.

I have put start time, and end time in the code itself.
You can also this in my code, so 2.5 seconds took this peace of code with 3.8 MB of image exact.

_**start = time.Now()**_
r.ParseMulitpartForm(0)
file, handle, err := r.FormFile("IMAGE")
if err != nil {

}
defer file.Close()
**_elasped = time.Since(start)_**
fmt.Println(elasped.Seconds())

The code you have shown does also measure transfer time, so if your line is that slow, then there is nothing go can do…

3.8 MB in 2.5 seconds is about 10 Mbit/s, which again is an artificial limit that I have often seen in windows on the loopback interface…

Is there anything else which I can try, which can tell me exactly why it is taking time ?

Where are you uploading this? Is it to localhost, or to a server somewhere? If you are not uploading to localhost, try https://speedtest.net and tell us what speeds you are getting.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.