简体   繁体   中英

Go chunk upload

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.

GoDoc

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

GoDoc

   // 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM