Does go support chunk upload? I am going to upload file as one-part multipart upload. As far as I know:
type Part
represents a single part in a multipart body and func (*Part) Read
reads the body of a part, after its headers and before the next part (if any) begins.
I assume that Reader
doesn't bother is it chunk upload or not, it just read bytes until EOF.
type Part struct {
// r is either a reader directly reading from mr, or it's a
// wrapper around such a reader, decoding the
// Content-Transfer-Encoding
r io.Reader
// If Body is present, Content-Length is <= 0 and TransferEncoding
// hasn't been set to "identity", Write adds "Transfer-Encoding:
// chunked" to the header. Body is closed after it is sent.
func (r *Request) Write(w io.Writer) error {
return r.write(w, false, nil, nil)
}
How should I handle multipart chunk upload as usual or I should adjust something?
The net/http
client and server support chunked request bodies. The client automatically uses chunked encoding when the content length is not known at the time the headers are written. The application does not need to take any action to enable the feature.