go get github.com/byteark/byteark-sdk-go
Now the only feature availabled is creating signed URL with ByteArk Signature Version 2.
First, import ByteArk's SDK in your code and call CreateSigner()
to create Signer.
import (
bytearkSignedURL "github.com/byteark/byteark-sdk-go"
)
The CreateSigner()
required one parameter SignerOptions
, which you can use provided SignerOptions
via SDK.
signerOptions := bytearkSignedURL.SignerOptions{
AccessID: "2Aj6Wkge4hi1ZYLp0DBG",
AccessSecret: "31sX5C0lcBiWuGPTzRszYvjxzzI3aCZjJi85ZyB7",
}
createSignerErr := bytearkSignedURL.CreateSigner(signerOptions)
if createSignerErr != nil {
panic(createSignerErr)
}
After create Signer you can call Sign function via SDK. Sign()
function also consume 3 parameters, url, expires and signOptions. SignOptions
is also provided by the SDK. Sign()
return signedURL and error.
signOptions := bytearkSignedURL.SignOptions{
"path_prefix": "/live/",
}
signedURL, err := bytearkSignedURL.Sign(
"https://example.cdn.byteark.com/path/to/file.png",
1514764800,
signOptions,
)
func CreateSigner(options SignerOptions) error
Create and update initial value of signer in sigleton pattern.
func Sign(url string, expires int, options SignOptions) (string, error)
Sign input url with expire date and option.
func Verify(url string, now int) (bool, error)
Verfiy signedURL that already sign by sign function.
type SignerOptions struct {
AccessID string
AccessSecret string
DefaultAge int
SkipURLEncoding bool
}
type SignOptions map[string]string