我使用go sdk从s3获取文件。 虽然响应表明ContentLength,但是从正文中读取的实际内容并没有填满我的缓冲区。
响应
{
AcceptRanges: "bytes",
Body: buffer(0xc0421d6cc0),
ContentEncoding: "utf-8",
ContentLength: 13,
ContentType: "application/json",
ETag: "\"a15ce1024b219fd76684ba1561d23ccc\"",
LastModified: 2017-02-09 15:16:45 +0000 UTC,
Metadata: {
}
}
码
var buf []byte
r, err := resp.Body.Read(buf)
if err != nil {
return "", err
}
defer resp.Body.Close()
fmt.Printf("read %d, buff %d", r, len(buf))
"read 0, buff 0"