api_object.go 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. package s3
  2. import (
  3. "github.com/ks3sdklib/aws-sdk-go/aws"
  4. "io"
  5. "time"
  6. )
  7. type AppendObjectInput struct {
  8. // The name of the bucket.
  9. Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"`
  10. // The name of the object.
  11. Key *string `location:"uri" locationName:"Key" type:"string" required:"true"`
  12. // The starting position of the AppendObject operation.
  13. // When the AppendObject operation is successful, the x-kss-next-append-position header describes the starting position of the next operation.
  14. Position *int64 `location:"querystring" locationName:"position" type:"integer" required:"true"`
  15. // The readable body payload to send to KS3.
  16. Body io.Reader `type:"blob"`
  17. // The canned ACL to apply to the object.
  18. ACL *string `location:"header" locationName:"x-amz-acl" type:"string"`
  19. // Specifies caching behavior along the request/reply chain.
  20. CacheControl *string `location:"header" locationName:"Cache-Control" type:"string"`
  21. // Specifies presentational information for the object.
  22. ContentDisposition *string `location:"header" locationName:"Content-Disposition" type:"string"`
  23. // Specifies what content encodings have been applied to the object and thus
  24. // what decoding mechanisms must be applied to obtain the media-type referenced
  25. // by the Content-Type header field.
  26. ContentEncoding *string `location:"header" locationName:"Content-Encoding" type:"string"`
  27. // Size of the body in bytes. This parameter is useful when the size of the
  28. // body cannot be determined automatically.
  29. ContentLength *int64 `location:"header" locationName:"Content-Length" type:"integer"`
  30. // Calculate MD5 value for message content (excluding header)
  31. ContentMD5 *string `location:"header" locationName:"Content-MD5" type:"string"`
  32. // A standard MIME type describing the format of the object data.
  33. ContentType *string `location:"header" locationName:"Content-Type" type:"string"`
  34. // When using Expect: 100-continue, the client will only send the request body after receiving confirmation from the server.
  35. // If the information in the request header is rejected, the client will not send the request body.
  36. Expect *string `location:"header" locationName:"Expect" type:"string"`
  37. // The date and time at which the object is no longer cacheable.
  38. Expires *time.Time `location:"header" locationName:"Expires" type:"timestamp" timestampFormat:"rfc822"`
  39. // A map of metadata to store with the object in S3.
  40. Metadata map[string]*string `location:"headers" locationName:"x-amz-meta-" type:"map"`
  41. // The type of storage to use for the object. Defaults to 'STANDARD'.
  42. StorageClass *string `location:"header" locationName:"x-amz-storage-class" type:"string"`
  43. // Set the maximum allowed size for a single addition of content
  44. ContentMaxLength *int64 `location:"header" locationName:"x-amz-content-maxlength" type:"integer"`
  45. // Specifies the object tag of the object. Multiple tags can be set at the same time, such as: TagA=A&TagB=B.
  46. // Note: Key and Value need to be URL-encoded first. If an item does not have "=", the Value is considered to be an empty string.
  47. Tagging *string `location:"header" locationName:"x-amz-tagging" type:"string"`
  48. // Allows grantee to read the object data and its metadata.
  49. GrantRead *string `location:"header" locationName:"x-amz-grant-read" type:"string"`
  50. // Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.
  51. GrantFullControl *string `location:"header" locationName:"x-amz-grant-full-control" type:"string"`
  52. // The Server-side encryption algorithm used when storing this object in KS3, eg: AES256.
  53. ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
  54. // Specifies the algorithm to use to when encrypting the object, eg: AES256.
  55. SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
  56. // Specifies the customer-provided encryption key for KS3 to use in encrypting data.
  57. SSECustomerKey *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key" type:"string"`
  58. // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321.
  59. SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
  60. // Progress callback function
  61. ProgressFn aws.ProgressFunc `location:"function"`
  62. // Set extend request headers. If the existing fields do not support setting the request header you need, you can set it through this field.
  63. ExtendHeaders map[string]*string `location:"extendHeaders" type:"map"`
  64. // Set extend query params. If the existing fields do not support setting the query param you need, you can set it through this field.
  65. ExtendQueryParams map[string]*string `location:"extendQueryParams" type:"map"`
  66. metadataAppendObjectInput `json:"-" xml:"-"`
  67. }
  68. type metadataAppendObjectInput struct {
  69. SDKShapeTraits bool `type:"structure" payload:"Body"`
  70. }
  71. type AppendObjectOutput struct {
  72. // Entity tag for the uploaded object.
  73. ETag *string `location:"header" locationName:"ETag" type:"string"`
  74. // The position that should be provided for the next request, which is the size of the current object.
  75. NextAppendPosition *int64 `location:"header" locationName:"x-amz-next-append-position" type:"integer"`
  76. // The type of Object.
  77. ObjectType *string `location:"header" locationName:"x-amz-object-type" type:"string"`
  78. // The Server-side encryption algorithm used when storing this object in KS3, eg: AES256.
  79. ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string"`
  80. // If server-side encryption with a customer-provided encryption key was requested,
  81. // the response will include this header confirming the encryption algorithm used.
  82. SSECustomerAlgorithm *string `location:"header" locationName:"x-amz-server-side-encryption-customer-algorithm" type:"string"`
  83. // If server-side encryption with a customer-provided encryption key was requested,
  84. // the response will include this header to provide round trip message integrity
  85. // verification of the customer-provided encryption key.
  86. SSECustomerKeyMD5 *string `location:"header" locationName:"x-amz-server-side-encryption-customer-key-MD5" type:"string"`
  87. Metadata map[string]*string `location:"headers" type:"map"`
  88. StatusCode *int64 `location:"statusCode" type:"integer"`
  89. metadataAppendObjectOutput `json:"-" xml:"-"`
  90. }
  91. type metadataAppendObjectOutput struct {
  92. SDKShapeTraits bool `type:"structure"`
  93. }
  94. // AppendObjectRequest generates a request for the AppendObject operation.
  95. func (c *S3) AppendObjectRequest(input *AppendObjectInput) (req *aws.Request, output *AppendObjectOutput) {
  96. op := &aws.Operation{
  97. Name: "AppendObject",
  98. HTTPMethod: "POST",
  99. HTTPPath: "/{Bucket}/{Key+}?append",
  100. }
  101. if input == nil {
  102. input = &AppendObjectInput{}
  103. }
  104. req = c.newRequest(op, input, output)
  105. if input.ProgressFn != nil {
  106. req.ProgressFn = input.ProgressFn
  107. }
  108. output = &AppendObjectOutput{}
  109. req.Data = output
  110. return
  111. }
  112. // AppendObject is used to append data to an Appendable object.
  113. func (c *S3) AppendObject(input *AppendObjectInput) (*AppendObjectOutput, error) {
  114. req, out := c.AppendObjectRequest(input)
  115. err := req.Send()
  116. return out, err
  117. }
  118. func (c *S3) AppendObjectWithContext(ctx aws.Context, input *AppendObjectInput) (*AppendObjectOutput, error) {
  119. req, out := c.AppendObjectRequest(input)
  120. req.SetContext(ctx)
  121. err := req.Send()
  122. return out, err
  123. }