doc_custom.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // Upload Managers
  2. //
  3. // The s3manager package's Uploader provides concurrent upload of content to S3
  4. // by taking advantage of S3's Multipart APIs. The Uploader also supports both
  5. // io.Reader for streaming uploads, and will also take advantage of io.ReadSeeker
  6. // for optimizations if the Body satisfies that type. Once the Uploader instance
  7. // is created you can call Upload concurrently from multiple goroutines safely.
  8. //
  9. // // The session the S3 Uploader will use
  10. // sess := session.Must(session.NewSession())
  11. //
  12. // // Create an uploader with the session and default options
  13. // uploader := s3manager.NewUploader(sess)
  14. //
  15. // f, err := os.Open(filename)
  16. // if err != nil {
  17. // return fmt.Errorf("failed to open file %q, %v", filename, err)
  18. // }
  19. //
  20. // // Upload the file to S3.
  21. // result, err := uploader.Upload(&s3manager.UploadInput{
  22. // Bucket: aws.String(myBucket),
  23. // Key: aws.String(myString),
  24. // Body: f,
  25. // })
  26. // if err != nil {
  27. // return fmt.Errorf("failed to upload file, %v", err)
  28. // }
  29. // fmt.Printf("file uploaded to, %s\n", aws.StringValue(result.Location))
  30. //
  31. // See the s3manager package's Uploader type documentation for more information.
  32. // https://docs.aws.amazon.com/sdk-for-go/api/service/s3/s3manager/#Uploader
  33. //
  34. // Download Manager
  35. //
  36. // The s3manager package's Downloader provides concurrently downloading of Objects
  37. // from S3. The Downloader will write S3 Object content with an io.WriterAt.
  38. // Once the Downloader instance is created you can call Download concurrently from
  39. // multiple goroutines safely.
  40. //
  41. // // The session the S3 Downloader will use
  42. // sess := session.Must(session.NewSession())
  43. //
  44. // // Create a downloader with the session and default options
  45. // downloader := s3manager.NewDownloader(sess)
  46. //
  47. // // Create a file to write the S3 Object contents to.
  48. // f, err := os.Create(filename)
  49. // if err != nil {
  50. // return fmt.Errorf("failed to create file %q, %v", filename, err)
  51. // }
  52. //
  53. // // Write the contents of S3 Object to the file
  54. // n, err := downloader.Download(f, &s3.GetObjectInput{
  55. // Bucket: aws.String(myBucket),
  56. // Key: aws.String(myString),
  57. // })
  58. // if err != nil {
  59. // return fmt.Errorf("failed to download file, %v", err)
  60. // }
  61. // fmt.Printf("file downloaded, %d bytes\n", n)
  62. //
  63. // See the s3manager package's Downloader type documentation for more information.
  64. // https://docs.aws.amazon.com/sdk-for-go/api/service/s3/s3manager/#Downloader
  65. //
  66. // Get Bucket Region
  67. //
  68. // GetBucketRegion will attempt to get the region for a bucket using a region
  69. // hint to determine which AWS partition to perform the query on. Use this utility
  70. // to determine the region a bucket is in.
  71. //
  72. // sess := session.Must(session.NewSession())
  73. //
  74. // bucket := "my-bucket"
  75. // region, err := s3manager.GetBucketRegion(ctx, sess, bucket, "us-west-2")
  76. // if err != nil {
  77. // if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "NotFound" {
  78. // fmt.Fprintf(os.Stderr, "unable to find bucket %s's region not found\n", bucket)
  79. // }
  80. // return err
  81. // }
  82. // fmt.Printf("Bucket %s is in %s region\n", bucket, region)
  83. //
  84. // See the s3manager package's GetBucketRegion function documentation for more information
  85. // https://docs.aws.amazon.com/sdk-for-go/api/service/s3/s3manager/#GetBucketRegion
  86. //
  87. // S3 Crypto Client
  88. //
  89. // The s3crypto package provides the tools to upload and download encrypted
  90. // content from S3. The Encryption and Decryption clients can be used concurrently
  91. // once the client is created.
  92. //
  93. // sess := session.Must(session.NewSession())
  94. //
  95. // // Create the decryption client.
  96. // svc := s3crypto.NewDecryptionClient(sess)
  97. //
  98. // // The object will be downloaded from S3 and decrypted locally. By metadata
  99. // // about the object's encryption will instruct the decryption client how
  100. // // decrypt the content of the object. By default KMS is used for keys.
  101. // result, err := svc.GetObject(&s3.GetObjectInput {
  102. // Bucket: aws.String(myBucket),
  103. // Key: aws.String(myKey),
  104. // })
  105. //
  106. // See the s3crypto package documentation for more information.
  107. // https://docs.aws.amazon.com/sdk-for-go/api/service/s3/s3crypto/
  108. //
  109. package s3