本文整理匯總了Golang中github.com/AdRoll/goamz/s3.Bucket.GetResponseWithHeaders方法的典型用法代碼示例。如果您正苦於以下問題:Golang Bucket.GetResponseWithHeaders方法的具體用法?Golang Bucket.GetResponseWithHeaders怎麽用?Golang Bucket.GetResponseWithHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/AdRoll/goamz/s3.Bucket
的用法示例。
在下文中一共展示了Bucket.GetResponseWithHeaders方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getClientRecord
// Read a single client record using a partial read from S3 using the given
// headers, which should contain a "Range: bytes=M-N" header.
func getClientRecord(bucket *s3.Bucket, o *MessageLocation, headers map[string][]string) ([]byte, error) {
resp, err := bucket.GetResponseWithHeaders(o.Key, headers)
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err == nil && len(body) != int(o.Length) {
err = fmt.Errorf("Unexpected body length: %d != %d\n", len(body), o.Length)
}
return body, err
}
示例2: getS3Reader
// Callers must call Close() on rc.
func getS3Reader(bucket *s3.Bucket, s3Key string, offset uint64) (rc io.ReadCloser, err error) {
if offset == 0 {
rc, err = bucket.GetReader(s3Key)
return
}
headers := map[string][]string{
"Range": []string{fmt.Sprintf("bytes=%d-", offset)},
}
resp, err := bucket.GetResponseWithHeaders(s3Key, headers)
if resp != nil {
rc = resp.Body
}
return
}