Documentation ¶
Index ¶
- Constants
- Variables
- func ReplaceFilepickerURL(addr string) (err error)
- type AlignOption
- type Blob
- type Client
- func (c *Client) ConvertAndStore(src *Blob, opt *ConvertOpts) (*Blob, error)
- func (c *Client) DownloadTo(src *Blob, opt *DownloadOpts, dst io.Writer) (int64, error)
- func (c *Client) DownloadToFile(src *Blob, opt *DownloadOpts, filedir string) error
- func (c *Client) PickURL(dataURL string, opt *PickOpts) (*Blob, error)
- func (c *Client) Remove(src *Blob, opt *RemoveOpts) error
- func (c *Client) Stat(src *Blob, opt *StatOpts) (Metadata, error)
- func (c *Client) Store(name string, opt *StoreOpts) (*Blob, error)
- func (c *Client) StoreURL(dataURL string, opt *StoreOpts) (*Blob, error)
- func (c *Client) Write(src *Blob, name string, opt *WriteOpts) (*Blob, error)
- func (c *Client) WriteURL(src *Blob, dataURL string, opt *WriteOpts) (*Blob, error)
- type ConvertOpts
- type DownloadOpts
- type FitOption
- type Fperror
- type MetaTag
- type Metadata
- func (md Metadata) Container() (container string, ok bool)
- func (md Metadata) Filename() (filename string, ok bool)
- func (md Metadata) Height() (height uint64, ok bool)
- func (md Metadata) Location() (location Storage, ok bool)
- func (md Metadata) Md5Hash() (md5hash string, ok bool)
- func (md Metadata) Mimetype() (mimetype string, ok bool)
- func (md Metadata) Path() (path string, ok bool)
- func (md Metadata) Size() (size uint64, ok bool)
- func (md Metadata) Uploaded() (uploaded time.Time, ok bool)
- func (md Metadata) Width() (width uint64, ok bool)
- func (md Metadata) Writeable() (writeable, ok bool)
- type Method
- type PickOpts
- type Policy
- type PolicyOpts
- type RemoveOpts
- type Security
- type StatOpts
- type Storage
- type StoreOpts
- type WriteOpts
Examples ¶
Constants ¶
const ( FitClip = FitOption("clip") FitCrop = FitOption("crop") FitScale = FitOption("scale") FitMax = FitOption("max") )
TODO : (ppknap)
const ( AlignTop = AlignOption("top") AlignBottom = AlignOption("bottom") AlignLeft = AlignOption("left") AlignRight = AlignOption("right") AlignFaces = AlignOption("faces") )
TODO : (ppknap)
const ( S3 = Storage("S3") // Amazon S3 bucket. Azure = Storage("azure") // Azure blob storage container. Dropbox = Storage("dropbox") // Dropbox folder. Rackspace = Storage("rackspace") // Rackspace cloud files container. )
TODO : (ppknap)
const ( TagSize = MetaTag("size") TagMimetype = MetaTag("mimetype") TagFilename = MetaTag("filename") TagWidth = MetaTag("width") TagHeight = MetaTag("height") TagUploaded = MetaTag("uploaded") TagWriteable = MetaTag("writeable") TagMd5Hash = MetaTag("md5") TagLocation = MetaTag("location") TagPath = MetaTag("path") TagContainer = MetaTag("container") )
TODO : (ppknap)
const ( MetPick = Method("pick") // Pick methods. MetRead = Method("read") // Download methods. MetStat = Method("stat") // Stat method. MetWrite = Method("write") // Write method. MetWriteurl = Method("writeUrl") // WriteURL method. MetStore = Method("store") // Store methods. MetConvert = Method("convert") // Convert method. MetRemove = Method("remove") // Remove method. )
TODO : (ppknap)
const UserAgentID = "filepicker-go 0.1"
UserAgentID TODO : (ppknap)
Variables ¶
var FilepickerURL = "https://www.filepicker.io/"
FilepickerURL is a link to filepicker.io service.
Functions ¶
func ReplaceFilepickerURL ¶
Types ¶
type AlignOption ¶
type AlignOption string
AlignOption defines how the image is aligned when resizing and using the "fit" parameter.
type Blob ¶
type Blob struct { // URL points to where the file is stored. URL string `json:"url,omitempty"` // Filename is the name of the file, if available. Filename string `json:"filename,omitempty"` // Mimetype is the mimetype of the file, if available. Mimetype string `json:"type,omitempty"` // Size is the size of the file in bytes. When this value is not available, // the user can get it by using Client.Stat method. Size uint64 `json:"size,omitempty"` // Key shows where in the file storage the data was put. Key string `json:"key,omitempty"` // Container points to the storage in which the file was put. Container Storage `json:"container,omitempty"` // Writeable specifies whether the underlying file is writeable. Writeable bool `json:"isWriteable,omitempty"` // Path indicates Blob's position in the hierarchy of files uploaded when // {folders:true} is set. Path string `json:"path,omitempty"` }
Blob contains information about the stored file.
type Client ¶
Client TODO : (ppknap)
func NewClientStorage ¶
NewClientStorage TODO : (ppknap)
func (*Client) ConvertAndStore ¶
func (c *Client) ConvertAndStore(src *Blob, opt *ConvertOpts) (*Blob, error)
ConvertAndStore TODO : (ppknap)
func (*Client) DownloadTo ¶
DownloadTo TODO : (ppknap)
func (*Client) DownloadToFile ¶
func (c *Client) DownloadToFile(src *Blob, opt *DownloadOpts, filedir string) error
DownloadToFile TODO : (ppknap)
func (*Client) PickURL ¶
PickURL creates a symlink to the underlaying file. Thus, if the user deletes the file from its storage, the blob object returned from this call will be invalid.
func (*Client) Remove ¶
func (c *Client) Remove(src *Blob, opt *RemoveOpts) error
Remove is used to delete a file from Filepicker.io and any underlying storage.
func (*Client) Store ¶
Store opens the named file and sends it content to client's storage bucket. If there is no error, this function returns a blob object that contains information about the stored file.
StoreOpt defines how filepicker.io will store the data. If a nil pointer is provided, this function will use default storage options.
func (*Client) StoreURL ¶
StoreURL takes a URL that points to the data to store and sends them directly to client's storage bucket. If the call succeeds, this function will return a blob object that contains information about the stored file.
StoreOpt defines how filepicker.io will store the data. If a nil pointer is provided, this function will use default storage options.
type ConvertOpts ¶
type ConvertOpts struct { // Width of the inputted image, in pixels. This property is ignored when the // file is not an image. Width int `json:"width,omitempty"` // Height of the inputted image, in pixels. This property is ignored when // the file is not an image. Height int `json:"height,omitempty"` // Fit specifies how to resize the image. Fit FitOption `json:"fit,omitempty"` // Align determines how the image is aligned when resizing and using the // "Fit" parameter. Defaults to cropping to the center of the image. Align AlignOption `json:"align,omitempty"` // Format TODO : (ppknap) Format string `json:"format,omitempty"` // Compress property works only for jpeg and png files. It specifies whether // image should be compressed. Compress bool `json:"compress,omitempty"` // Quality specifies the quality of the resultant image. It is ignored when // the file is not of jpeg type. Quality int8 `json:"quality,omitempty"` // Filename specifies the name of the stored file. If this variable is // empty, filepicker service will choose the label automatically. Filename string `json:"filename,omitempty"` // Location contains the name of file storage service which will be used to // store a file. If this field is not set, filepicker client will use Simple // Storage Service (S3). Location Storage `json:"storeLocation,omitempty"` // Path to store the file at within the specified file store. If the // provided path ends in a '/', it will be treated as a folder. Path string `json:"storePath,omitempty"` // Container or a bucket in the specified file store where the file should // end up. If this parameter is omitted, the file is stored in the default // container specified in the user's developer portal. Container string `json:"storeContainer,omitempty"` // Access allows to use direct links to underlying file store service. Access string `json:"storeAccess,omitempty"` // Security stores Filepicker.io policy and signature members. If you enable // security option in your developer portal, these values must be set in // order to perform a valid request call. Security }
ConvertOpts structure allows the user to set conversion and security options.
type DownloadOpts ¶
type DownloadOpts struct { // Base64Decode indicates whether the data should be first decoded from // base64 before being written to the file. Base64Decode bool `json:"base64decode,omitempty"` // Security stores Filepicker.io policy and signature members. If you enable // security option in your developer portal, these values must be set in // order to perform a valid request call. Security }
DownloadOpts structure defines a set of additional options that may be required to successfully download the stored data.
type Metadata ¶
type Metadata map[string]interface{}
Metadata TODO : (ppkanp)
func (Metadata) Container ¶
Container returns the storage container of a stored file. The second value (ok) is set to false if the information is unavailable.
func (Metadata) Filename ¶
Filename returns the name of a stored file. The second value (ok) is set to false if the information is unavailable.
func (Metadata) Height ¶
Height returns the height of a stored image. If the file is not an image or the information about its size is unavailable, the second value (ok) will be set to false.
func (Metadata) Location ¶
Location returns the storage location (S3, etc.) of a stored file. The second value (ok) is set to false if the information is unavailable.
func (Metadata) Md5Hash ¶
Md5Hash returns the MD5 hash of the stored file. The second value (ok) is set to false if the information is unavailable.
func (Metadata) Mimetype ¶
Mimetype returns the type of a stored file. The second value (ok) is set to false if the information is unavailable.
func (Metadata) Path ¶
Path returns the storage path of a stored file. The second value (ok) is set to false if the information is unavailable.
func (Metadata) Size ¶
Size returns the size of a stored file in bytes. The second value (ok) is set to false if the information is unavailable.
func (Metadata) Uploaded ¶
Uploaded returns the upload time of a stored file. The second value (ok) is set to false if the information is unavailable.
type PickOpts ¶
type PickOpts struct { // Security stores Filepicker.io policy and signature members. If you enable // security option in your developer portal, these values must be set in // order to perform a valid request call. Security }
PickOpts structure allows the user to configure security options when picking a file.
type Policy ¶
type Policy string
Policy stores the information about what the user can or cannot do.
func MakePolicy ¶
func MakePolicy(po *PolicyOpts) (policy Policy, err error)
MakePolicy creates a new Policy object from provided policy options.
type PolicyOpts ¶
type PolicyOpts struct { // Expiry is the expiration date of the policy after which it will no longer // be valid. This field is required. Expiry time.Time `json:"-"` // Handle is an unique file handle that you would like to access. It can be // obtained from Blob object by calling Handle() method. Handle string `json:"handle,omitempty"` // Call defines the list of function calls which this policy will be allowed // to make. Call []Method `json:"call,omitempty"` // MaxSize sets the maximum object size limit. This property only applies to // the store command. MaxSize uint64 `json:"maxsize,omitempty"` // MaxSize sets the minimum object size limit. This property only applies to // the store command. MinSize uint64 `json:"minsize,omitempty"` // Path field is valid only for policies that store files. It is a perl-like // regular expression that must match the path that the files will be stored // under. Defaults to allowing any path ('.*'). Path string `json:"path,omitempty"` // Container field is valid only for policies that store files. It is a // perl-like regular expression that must match the container that the files // will be stored under. Defaults to allowing any container ('.*'). Container string `json:"container,omitempty"` }
PolicyOpts structure defines the properties of the policy.
func (*PolicyOpts) MarshalJSON ¶
func (po *PolicyOpts) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface. It transforms Expiry field representation to UNIX time value. By default, marshaling time.Time structure produces a quoted string in RFC 3339 format.
type RemoveOpts ¶
type RemoveOpts struct { // Security stores Filepicker.io policy and signature members. If you enable // security option in your developer portal, these values must be set in // order to perform a valid request call. Security }
RemoveOpts structure allows the user to set additional options when removing the data.
type Security ¶
type Security struct { Policy Policy `json:"policy,omitempty"` Signature string `json:"signature,omitempty"` }
Security type stores the piece of information that is required to access secured URLs.
func MakeSecurity ¶
MakeSecurity creates a new Security object from the given secret and policy instances.
You should not store your secret in your code. Instead, call this function once and then use obtained strings to initialize Security objects directly.
Example ¶
package main import ( "log" "time" "github.com/filepicker/filepicker-go/filepicker" ) func main() { options := &filepicker.PolicyOpts{ Expiry: time.Unix(1508141504, 0), Handle: "KW9EJhYtS6y48Whm2S6D", } policy, err := filepicker.MakePolicy(options) if err != nil { log.Fatalln("cannot create policy:", err) } security := filepicker.MakeSecurity("Z3IYZSH2UJA7VN3QYFVSVCF7PI", policy) log.Printf("P: %s\nS: %s\n", security.Policy, security.Signature) }
Output:
type StatOpts ¶
type StatOpts struct { // Tags TODO : (ppknap) Tags []MetaTag `json:"tags,omitempty"` // Security stores Filepicker.io policy and signature members. If you enable // security option in your developer portal, these values must be set in // order to perform a valid request call. Security }
StatOpts TODO : (ppknap)
type Storage ¶
type Storage string
Storage represents cloud storage services supported by filepicker.io client.
type StoreOpts ¶
type StoreOpts struct { // Filename specifies the name of the stored file. If this variable is // empty, filepicker service will choose the label automatically. Filename string `json:"filename,omitempty"` // Mimetype specifies the type of the stored file. Mimetype string `json:"mimetype,omitempty"` // Location contains the name of file storage service which will be used to // store a file. If this field is not set, filepicker client will use Simple // Storage Service (S3). Location Storage `json:"location,omitempty"` // Path to store the file at within the specified file store. If the // provided path ends in a '/', it will be treated as a folder. Path string `json:"path,omitempty"` // Container or a bucket in the specified file store where the file should // end up. If this parameter is omitted, the file is stored in the default // container specified in the user's developer portal. Container string `json:"container,omitempty"` // Base64Decode indicates whether the data should be first decoded from // base64 before being written to the file. Base64Decode bool `json:"base64decode,omitempty"` // Access allows to use direct links to underlying file store service. Access string `json:"access,omitempty"` // Security stores Filepicker.io policy and signature members. If you enable // security option in your developer portal, these values must be set in // order to perform a valid request call. Security }
StoreOpts structure allows the user to configure how to store the data.
type WriteOpts ¶
type WriteOpts struct { // Base64Decode indicates whether the data should be first decoded from // base64 before being written to the file. Base64Decode bool `json:"base64decode,omitempty"` // Security stores Filepicker.io policy and signature members. If you enable // security option in your developer portal, these values must be set in // order to perform a valid request call. Security }
WriteOpts structure defines a set of additional options that may be required to successfully rewrite the contents of the stored file.