model.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package oss
  2. import (
  3. "hash"
  4. "io"
  5. "net/http"
  6. )
  7. // Response defines HTTP response from OSS
  8. type Response struct {
  9. StatusCode int
  10. Headers http.Header
  11. Body io.ReadCloser
  12. ClientCRC uint64
  13. ServerCRC uint64
  14. }
  15. func (r *Response) Read(p []byte) (n int, err error) {
  16. return r.Body.Read(p)
  17. }
  18. // Close close http reponse body
  19. func (r *Response) Close() error {
  20. return r.Body.Close()
  21. }
  22. // PutObjectRequest is the request of DoPutObject
  23. type PutObjectRequest struct {
  24. ObjectKey string
  25. Reader io.Reader
  26. }
  27. // GetObjectRequest is the request of DoGetObject
  28. type GetObjectRequest struct {
  29. ObjectKey string
  30. }
  31. // GetObjectResult is the result of DoGetObject
  32. type GetObjectResult struct {
  33. Response *Response
  34. ClientCRC hash.Hash64
  35. ServerCRC uint64
  36. }
  37. // AppendObjectRequest is the requtest of DoAppendObject
  38. type AppendObjectRequest struct {
  39. ObjectKey string
  40. Reader io.Reader
  41. Position int64
  42. }
  43. // AppendObjectResult is the result of DoAppendObject
  44. type AppendObjectResult struct {
  45. NextPosition int64
  46. CRC uint64
  47. }
  48. // UploadPartRequest is the request of DoUploadPart
  49. type UploadPartRequest struct {
  50. InitResult *InitiateMultipartUploadResult
  51. Reader io.Reader
  52. PartSize int64
  53. PartNumber int
  54. }
  55. // UploadPartResult is the result of DoUploadPart
  56. type UploadPartResult struct {
  57. Part UploadPart
  58. }