Documentation ¶
Index ¶
- type Client
- func (c *Client) GetServerVersion() (bi *common.BuildInfo, err error)
- func (c *Client) GetUpload(id string) (upload *Upload, err error)
- func (c *Client) GetUploadProtectedByPassword(id string, login string, password string) (upload *Upload, err error)
- func (c *Client) MakeRequest(req *http.Request) (resp *http.Response, err error)
- func (c *Client) NewUpload() *Upload
- func (c *Client) UploadFile(path string) (upload *Upload, file *File, err error)
- func (c *Client) UploadReader(name string, reader io.Reader) (upload *Upload, file *File, err error)
- func (c *Client) UploadRequest(upload *common.Upload, method, URL string, body io.Reader) (req *http.Request, err error)
- type File
- func (file *File) Delete() (err error)
- func (file *File) Download() (reader io.ReadCloser, err error)
- func (file *File) Error() error
- func (file *File) GetURL() (URL *url.URL, err error)
- func (file *File) Metadata() (details *common.File)
- func (file *File) RegisterUploadCallback(callback UploadCallback)
- func (file *File) Upload() (err error)
- func (file *File) WrapReader(wrapper func(reader io.ReadCloser) io.ReadCloser)
- type Upload
- func (upload *Upload) AddFileFromPath(name string) (file *File, err error)
- func (upload *Upload) AddFileFromReadCloser(name string, reader io.ReadCloser) (file *File)
- func (upload *Upload) AddFileFromReader(name string, reader io.Reader) (file *File)
- func (upload *Upload) Create() (err error)
- func (upload *Upload) Delete() (err error)
- func (upload *Upload) DownloadZipArchive() (reader io.ReadCloser, err error)
- func (upload *Upload) Files() (files []*File)
- func (upload *Upload) GetAdminURL() (u *url.URL, err error)
- func (upload *Upload) GetURL() (u *url.URL, err error)
- func (upload *Upload) ID() string
- func (upload *Upload) Metadata() (details *common.Upload)
- func (upload *Upload) Upload() (err error)
- type UploadCallback
- type UploadParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { *UploadParams // Default upload params for the Client. Those can be overridden per upload Debug bool // Display HTTP request and response and other helpful debug data URL string // URL of the Plik server ClientName string // X-ClientApp HTTP Header setting ClientVersion string // X-ClientVersion HTTP Header setting HTTPClient *http.Client // HTTP Client ot use to make the requests }
Client manage the process of communicating with a Plik server via the HTTP API
func (*Client) GetServerVersion ¶
GetServerVersion return the remote server version
func (*Client) GetUploadProtectedByPassword ¶
func (c *Client) GetUploadProtectedByPassword(id string, login string, password string) (upload *Upload, err error)
GetUploadProtectedByPassword fetch upload metadata from the server with login and password
func (*Client) MakeRequest ¶
MakeRequest perform an HTTP request to a Plik Server HTTP API.
- Manage request header X-ClientApp and X-ClientVersion
- Log the request and response if the client is in Debug mode
- Parsing response error to Go error
func (*Client) NewUpload ¶
NewUpload create a new Upload object with the client default upload params
func (*Client) UploadFile ¶
UploadFile is a handy wrapper to upload a file from the filesystem
type File ¶
File contains all relevant info needed to upload data to a Plik server
func (*File) Download ¶
func (file *File) Download() (reader io.ReadCloser, err error)
Download downloads all the upload files in a zip archive
func (*File) RegisterUploadCallback ¶
func (file *File) RegisterUploadCallback(callback UploadCallback)
RegisterUploadCallback a callback to be executed after the file have been uploaded
func (*File) WrapReader ¶
func (file *File) WrapReader(wrapper func(reader io.ReadCloser) io.ReadCloser)
WrapReader a convenient function to alter the content of the file on the file ( encrypt / display progress / ... )
type Upload ¶
type Upload struct { UploadParams // contains filtered or unexported fields }
Upload store the necessary data to upload files to a Plik server
func (*Upload) AddFileFromPath ¶
AddFileFromPath add a new file from a filesystem path
func (*Upload) AddFileFromReadCloser ¶
func (upload *Upload) AddFileFromReadCloser(name string, reader io.ReadCloser) (file *File)
AddFileFromReadCloser add a new file from a filename and io.ReadCloser
func (*Upload) AddFileFromReader ¶
AddFileFromReader add a new file from a filename and io.Reader
func (*Upload) Delete ¶
Delete remove the upload and all the associated files from the remote server
func (*Upload) DownloadZipArchive ¶
func (upload *Upload) DownloadZipArchive() (reader io.ReadCloser, err error)
DownloadZipArchive downloads all the upload files in a zip archive
func (*Upload) GetAdminURL ¶
GetAdminURL return the URL page of the upload with upload admin rights
type UploadCallback ¶
UploadCallback to be executed once the file has been uploaded
type UploadParams ¶
type UploadParams struct { Stream bool // Don't store the file on the server OneShot bool // Force deletion of the file from the server after the first download Removable bool // Allow upload and upload files to be removed from the server at any time TTL int // Time in second before automatic deletion of the file from the server Comments string // Arbitrary comment to attach to the upload ( the web interface support markdown language ) Token string // Authentication token to link an upload to a Plik user Login string // HttpBasic protection for the upload Password string // Login and Password }
UploadParams store the different options available when uploading file to a Plik server One should add files to the upload before calling Create or Upload