Open client9 opened 10 years ago
I am interested in this feature, i need to change the content type and content encoding. I have been playing with GetResponseHeader from the original goaws/goaws lib, porting this function to this lib...
got this so far:
s3.go
func (b *Bucket) GetResponseWithHeaders(path string, headers map[string][]string) (data []byte, err error) {
req := &request{
bucket: b.Name,
path: path,
headers: headers,
}
fmt.Printf("**** initial headers: %v\n\n\n", req)
err = b.S3.prepare(req)
fmt.Printf("**** headers after prep: %v\n\n\n\n", req)
if err != nil {
return nil, err
}
for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); {
resp, err := b.S3.run(req, nil)
if shouldRetry(err) && attempt.HasNext() {
continue
}
if err != nil {
return nil, err
}
fmt.Printf("**** headers after get: %v\n\n\n", resp.Header)
data, err = ioutil.ReadAll(resp.Body)
resp.Body.Close()
return data, nil
}
panic("unreachable")
}
also added to S3 struct
aws.AttemptStrategy
this works, pulls back the data, how ever the headers do not seem to be sticking, on printing the headers, the last one shows the content type of the actual file being downloaded, not the one set...
still working on this.
Hola,
for S3, one can have custom HTTP headers on a PUT request but not on a GET request.
I would like parity here, but doing the following:
Likewise add a
GetHeader
, andGetReaderHeader
Kinda gross, but not sure of a better way that preserves API compatibility and/or rewrite.
thoughts? I'm happy to do a pull request.
nickg