Rewriting Response Headers
API Description
You can rewrite some HTTP/HTTPS response headers when downloading an object. The following table lists rewritable response headers.
| Parameter | Description |
|---|---|
| GetObjectInput.ResponseContentType | Rewrites Content-Type in HTTP/HTTPS responses. |
| GetObjectInput.ResponseContentLanguage | Rewrites Content-Language in HTTP/HTTPS responses. |
| GetObjectInput.ResponseExpires | Rewrites Expires in HTTP/HTTPS responses. |
| GetObjectInput.ResponseCacheControl | Rewrites Cache-Control in HTTP/HTTPS responses. |
| GetObjectInput.ResponseContentDisposition | Rewrites Content-Disposition in HTTP/HTTPS responses. |
| GetObjectInput.ResponseContentEncoding | Rewrites Content-Encoding in HTTP/HTTPS responses. |
Method Definition
func (obsClient ObsClient) GetObject(input *GetObjectInput) (output *GetObjectOutput, err error)
Method Definition If a Signed URL Is Used
func (obsClient ObsClient) GetObjectWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetObjectOutput, err error)
Request Parameters
| Field | Type | Optional or Mandatory |
|---|---|---|
| input | Mandatory |
Returned Results
| Field | Type |
|---|---|
| output | |
| err | error |
Sample Code
func main() { input := &obs.GetObjectInput{} input.Bucket = "bucketname" input.Key = "objectname" input.ResponseContentType = "image/jpeg" output, err := obsClient.GetObject(input) if err == nil { defer output.Body.Close() // Obtain the rewritten response headers. fmt.Printf("ContentType:%s\n", output.ContentType) } else if obsError, ok := err.(obs.ObsError); ok { fmt.Printf("Code:%s\n", obsError.Code) fmt.Printf("Message:%s\n", obsError.Message) } }
Last Article: Setting Object Properties
Next Article: Obtaining Customized Metadata
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.