更新时间:2022-02-10 GMT+08:00
上传对象
功能说明
上传对象到指定桶中。
方法定义
func (obsClient ObsClient) PutObject(input *PutObjectInput) (output *PutObjectOutput, err error)
使用带授权信息URL的方法定义
func (obsClient ObsClient) PutObjectWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *PutObjectOutput, err error)
请求参数
参数名 |
类型 |
约束 |
---|---|---|
input |
必选 |
返回结果
参数名 |
类型 |
---|---|
output |
|
err |
error |
代码样例
func main() { input := &obs.PutObjectInput{} input.Bucket = "bucketname" input.Key = "objectkey" input.Body = strings.NewReader("Hello OBS") output, err := obsClient.PutObject(input) if err == nil { fmt.Printf("RequestId:%s\n", output.RequestId) fmt.Printf("ETag:%s, StorageClass:%s\n", output.ETag, output.StorageClass) } else { if obsError, ok := err.(obs.ObsError); ok { fmt.Println(obsError.Code) fmt.Println(obsError.Message) } else { fmt.Println(err) } } }
父主题: 对象相关接口