go 支持 block 上传吗?
我将上传文件作为一份分段上传。
据我所知:type Part
表示多部分正文中的单个部分,func (*Part) Read
在其标题之后和下一部分(如果有)开始之前读取部分的主体。
我假设 Reader
不打扰是否是 block 上传,它只是读取字节直到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)
}
我应该如何像往常一样处理分段 block 上传,或者我应该调整一些东西?
最佳答案
net/http
客户端和服务器支持分 block 请求体。当在写入 header 时内容长度未知时,客户端会自动使用分 block 编码。应用程序无需执行任何操作即可启用该功能。
关于http - 去 block 上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63449026/