如何将 *multipart.FileHeader 中包含的文件的正文/内容读取到 GO 中的字节片 ([]byte) 中。
我唯一需要做的就是将内容读入一个巨大的字节片中,但当然我想要文件的确切大小。我想之后用 md5 对文件内容进行哈希处理。
// file is a *multipart.FileHeader gotten from http request.
fileContent, _ := file.Open()
var byteContainer []byte
byteContainer = make([]byte, 1000000)
fileContent.Read(byteContainer)
fmt.Println(byteContainer)
Run Code Online (Sandbox Code Playgroud)