Documentation ¶
Index ¶
- Constants
- Variables
- func BucketOfUploadAction(actionURL string) (string, error)
- func ReformatXAmzDate(in string) (string, error)
- func RegionOfUploadAction(actionURL string) (string, error)
- func RewriteXAmzDateHeader(h http.Header) error
- func TokenOfUploaderURL(uploaderURL string) (string, error)
- type AwsUpload
- func (a *AwsUpload) Acl() string
- func (a *AwsUpload) AwsKeyId() string
- func (a *AwsUpload) ContentType() string
- func (a AwsUpload) GetBucket() (string, error)
- func (a AwsUpload) GetRegion() (string, error)
- func (a *AwsUpload) Key() string
- func (a *AwsUpload) Request(body []byte) ([]byte, error)
- func (a *AwsUpload) ServerSignV2(r *request.Request) (string, error)
- func (a *AwsUpload) SignRequest(r *request.Request) error
- func (a AwsUpload) Signer() func(r *request.Request)
- func (a *AwsUpload) Upload(body io.Reader) (*s3manager.UploadOutput, error)
- func (a *AwsUpload) UploaderSigUrl() string
- func (a *AwsUpload) Url() string
- func (a *AwsUpload) V4Sig(req V4Request) (resp V4Response, err error)
- type AwsUploadF
- type UploadParameters
- type UploadRequest
- type UploaderSignatureRequest
- type UploaderSignatureResponse
- type V4Request
- type V4Response
Constants ¶
const ( DefaultCtype = "video/mp4" DefaultAcl = "private" )
Variables ¶
var CreatorFn func(UploadParameters) (AwsUploadF, error)
Functions ¶
func BucketOfUploadAction ¶
bucketOfUploadAction parses an "action" URL as received with GetUploadInfo, and returns the bucket name part of that URL.
Example:
const a = "https://synqfm.s3.amazonaws.com" bucket, err := bucketOfUploadAction(a) if err != nil { log.Fatal(err) } fmt.Println(bucket) // prints synqfm
func ReformatXAmzDate ¶
ReformatXAmzDate reformats the contents of a X-Amz-Date header into the format that https://uploader.synq.fm/uploader/signature expects.
Example:
const in = "20060102T150405Z" out, err := ReformatXAmzDate(in) if err != nil { log.Fatal(err) } fmt.Println(out) // Mon, 02 Jan 2006 15:04:05 UTC
func RegionOfUploadAction ¶
regionOfUploadAction parses an "action" URL as received with GetUploadInfo, and returns the region of the bucket that is the URL refers to.
This relies on heuristics, and will not work with certain styles of URLs.
See: http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
Example:
const a = "https://synqfm.s3.amazonaws.com" region, err := regionOfUploadAction(a) if err != nil { log.Fatal(err) } fmt.Println(region) // prints us-east-1
func RewriteXAmzDateHeader ¶
RewriteXAmzDateHeader rewrites the X-Amz-Date header, of an http.Header, into the format that https://uploader.synq.fm/uploader/signature expects.
Example:
h := http.Header{} h.Set("X-Amz-Date", "20060102T150405Z") err := RewriteXAmzDateHeader(h) if err != nil { log.Fatal(err) } fmt.Println(h.Get("X-Amz-Date")) // Mon, 2 Jan 2006 15:04:05 UTC
func TokenOfUploaderURL ¶
TokenOfUploaderURL parses an uploader URL string, and returns its token parameter.
Example:
const u = "https://uploader.synq.fm/uploader/" + "00000000000000000000000000000000" + "?token=11111111111111111111111111111111" token, err := TokenOfUploaderURL(u) if err != nil { log.Fatal(err) } fmt.Println(token) // prints 11111111111111111111111111111111
Types ¶
type AwsUpload ¶
type AwsUpload struct { UploadParams UploadParameters Uploader *s3manager.Uploader }
This is the struct that contains all the AWS settings
func (*AwsUpload) ContentType ¶
func (AwsUpload) GetBucket ¶
bucketOfUploadAction parses an "action" URL as received with GetUploadInfo, and returns the bucket name part of that URL.
Example:
const a = "https://synqfm.s3.amazonaws.com" bucket, err := bucketOfUploadAction(a) if err != nil { log.Fatal(err) } fmt.Println(bucket) // prints synqfm
func (AwsUpload) GetRegion ¶
regionOfUploadAction parses an "action" URL as received with GetUploadInfo, and returns the region of the bucket that is the URL refers to.
This relies on heuristics, and will not work with certain styles of URLs.
See: http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
Example:
const a = "https://synqfm.s3.amazonaws.com" region, err := regionOfUploadAction(a) if err != nil { log.Fatal(err) } fmt.Println(region) // prints us-east-1
func (*AwsUpload) ServerSignV2 ¶
func (*AwsUpload) SignRequest ¶
This runs as a handler within the Sign HandlerList and uses unicorn to sign the request This will replace whats in awssdk-go/aws/signer/v4/v4.go and its own "signWithBody" method https://docs.aws.amazon.com/general/latest/gr/signature-version-2.html https://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html
func (*AwsUpload) UploaderSigUrl ¶
type AwsUploadF ¶
type AwsUploadF interface {
Upload(io.Reader) (*s3manager.UploadOutput, error)
}
func NewAwsUpload ¶
func NewAwsUpload(params UploadParameters) (AwsUploadF, error)
UploadParameters is retrieved from the Unicorn API, so we're creating an AwsUpload from the settings
type UploadParameters ¶
type UploadParameters struct { Action string `json:"action"` AwsAccessKeyId string `json:"AWSAccessKeyId"` ContentType string `json:"Content-Type"` Policy string `json:"policy"` Signature string `json:"signature"` Acl string `json:"acl"` Region string `json:"region"` Key string `json:"key"` SuccessStatus string `json:"success_action_status"` SignatureUrl string `json:"signature_url"` VideoId string `json:"video_id"` AssetId string `json:"asset_id"` }
type UploadRequest ¶
type UploadRequest struct { AssetId string `json:"asset_id"` ContentType string `json:"content_type"` Ext string `json:"ext"` Type string `json:"type"` Acl string `json:"acl"` }
func NewUploadRequest ¶
func NewUploadRequest(data []byte) (UploadRequest, error)
func (UploadRequest) GetAcl ¶
func (u UploadRequest) GetAcl() string
func (UploadRequest) GetCType ¶
func (u UploadRequest) GetCType() string
func (UploadRequest) GetExt ¶
func (u UploadRequest) GetExt() string
func (UploadRequest) GetType ¶
func (u UploadRequest) GetType() string
func (*UploadRequest) ProcessCtype ¶
func (u *UploadRequest) ProcessCtype() error
type UploaderSignatureRequest ¶
type UploaderSignatureRequest struct {
Headers string `json:"headers"`
}
UploaderSignatureRequest is the request that is sent when using the embeddable web uploader's request signing service.
type UploaderSignatureResponse ¶
type UploaderSignatureResponse struct {
Signature string `json:"signature"`
}
UploaderSignatureResponse is the response that is received when using the embeddable web uploader's request signing service.
type V4Request ¶
type V4Request struct { Method string `json:"method"` Action string `json:"action"` Path string `json:"path"` Region string `json:"region"` RawQuery string `json:"raw_query"` Headers map[string]string `json:"headers"` }
func CreateV4Request ¶
func CreateV4Request(params UploadParameters, req *request.Request) V4Request