Documentation
¶
Overview ¶
Package client provides the pcopy client that can be used to its server
Index ¶
- type Client
- func (c *Client) Copy(reader io.ReadCloser, id string, ttl time.Duration, mode string, stream bool) (*server.File, error)
- func (c *Client) CopyFiles(files []string, id string, ttl time.Duration, mode string, stream bool) (*server.File, error)
- func (c *Client) FileInfo(id string) (*server.File, error)
- func (c *Client) Paste(writer io.Writer, id string) error
- func (c *Client) PasteFiles(dir string, id string) error
- func (c *Client) Reserve(id string) (*server.File, error)
- func (c *Client) ServerInfo() (*server.Info, error)
- func (c *Client) Verify(cert *x509.Certificate, key *crypto.Key) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a pcopy client. It can be used to communicate with the server to verify the user password, and ultimately to copy/paste files.
func (*Client) Copy ¶
func (c *Client) Copy(reader io.ReadCloser, id string, ttl time.Duration, mode string, stream bool) (*server.File, error)
Copy streams the data from reader to the server via a HTTP PUT request. The id parameter is the file identifier that can be used to paste the data later using Paste.
func (*Client) CopyFiles ¶
func (c *Client) CopyFiles(files []string, id string, ttl time.Duration, mode string, stream bool) (*server.File, error)
CopyFiles creates a ZIP archive of the given files and streams it to the server using the Copy method. No temporary ZIP archive is created on disk. It's all streamed.
func (*Client) Paste ¶
Paste reads the file with the given id from the server and writes it to writer.
func (*Client) PasteFiles ¶
PasteFiles reads the file with the given id from the server (assuming that it is a ZIP archive) and unpacks it to dir. This method creates a temporary file of the archive first before unpacking.
func (*Client) Reserve ¶
Reserve requests a file name from the server and reserves it for a very short period of time. This is a workaround to be able to stream to a random file ID.
func (*Client) ServerInfo ¶
ServerInfo queries the server for information (password salt, advertised address) required during the join operation. This method will first attempt to securely connect over HTTPS, and (if that fails) fall back to skipping certificate verification. In the latter case, it will download and return the server certificate so the client can pin them.