README

Package s3 signs HTTP requests for use with Amazon’s S3 API.

Documentation:
http://godoc.org/github.com/kr/s3
Expand ▾ Collapse ▴

Documentation

Overview

    Package s3 signs HTTP requests for Amazon S3 and compatible services.

    Index

    Examples

    Constants

    This section is empty.

    Variables

    View Source
    var DefaultService = &Service{Domain: "amazonaws.com"}

      DefaultService is the default Service used by Sign.

      Functions

      func AmazonBucket

      func AmazonBucket(subdomain string) string

        AmazonBucket returns everything up to the last '.' in subdomain. It is designed to be used with the Amazon service.

        "johnsmith.s3"           becomes "johnsmith"
        "johnsmith.s3-eu-west-1" becomes "johnsmith"
        "www.example.com.s3"     becomes "www.example.com"
        

        func IdentityBucket

        func IdentityBucket(subdomain string) string

          IdentityBucket returns subdomain. It is designed to be used with S3-compatible services that treat the entire subdomain as the bucket name, for example storage.io.

          func Sign

          func Sign(r *http.Request, k Keys)

            Sign signs an HTTP request with the given S3 keys.

            This function is a wrapper around DefaultService.Sign.

            Example
            Output:
            
            

            Types

            type Keys

            type Keys struct {
            	AccessKey string
            	SecretKey string
            
            	// SecurityToken is used for temporary security credentials.
            	// If set, it will be added to header field X-Amz-Security-Token
            	// before signing a request.
            	SecurityToken string
            }

              Keys holds a set of Amazon Security Credentials.

              type Service

              type Service struct {
              	// Domain is the service's root domain. It is used to extract
              	// the subdomain from an http.Request before passing the
              	// subdomain to Bucket.
              	Domain string
              
              	// Bucket derives the bucket name from a subdomain.
              	// If nil, AmazonBucket is used.
              	Bucket func(subdomain string) string
              }

                Service represents an S3-compatible service.

                func (*Service) Sign

                func (s *Service) Sign(r *http.Request, k Keys)

                  Sign signs an HTTP request with the given S3 keys for use on service s.

                  Source Files

                  Directories

                  Path Synopsis
                  Command s3cp copies a file to or from Amazon S3.
                  Command s3cp copies a file to or from Amazon S3.
                  Package s3util provides streaming transfers to and from Amazon S3.
                  Package s3util provides streaming transfers to and from Amazon S3.