Downloading Objects - Specified Conditions
API Description
When downloading an object, you can specify one or more conditions. Only when the conditions are met, the object will be downloaded. Otherwise, an error code will be returned and the download will fail.
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" format := "2006/01/02 15:04:05" t, _ := time.Parse(format, "2015/12/31 00:00:00") input.IfModifiedSince = t output, err := obsClient.GetObject(input) if err == nil { defer output.Body.Close() fmt.Printf("StorageClass:%s, ETag:%s, ContentType:%s, ContentLength:%d, LastModified:%s\n", output.StorageClass, output.ETag, output.ContentType, output.ContentLength, output.LastModified) } else if obsError, ok := err.(obs.ObsError); ok { fmt.Printf("Code:%s\n", obsError.Code) fmt.Printf("Message:%s\n", obsError.Message) } }
Last Article: Downloading Objects - Partially
Next Article: Downloading Objects - Resumable Transfer
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.