Documentation
¶
Overview ¶
Package pixeldrain provides a Pixeldrain client.
Example (Download) ¶
ctx := context.Background() id := "FILE_ID" apiKey := "YOUR API KEY IF NECESSARY" // Get the file information. info, err := pixeldrain.Default.File.GetFileInfo( file.NewGetFileInfoParamsWithContext(ctx).WithID(id), client.BasicAuth("", apiKey), ) if err != nil { log.Fatal(err) } // Open a file to store the downloaded contents. f, err := os.OpenFile(filepath.Join("~/Downloads", info.Payload.Name), os.O_CREATE|os.O_WRONLY, 0644) if err != nil { log.Fatal(err) } defer func() { if err := f.Close(); err != nil { log.Fatal(err) } }() // If a directory path is given, the downloaded file will be stored in the directory. _, err = pixeldrain.Default.File.DownloadFile( file.NewDownloadFileParamsWithContext(ctx).WithID(id), client.BasicAuth("", apiKey), f, ) if err != nil { log.Fatal(err) }
Output:
Example (Upload) ¶
// Open the target file. f, err := os.Open("example_test.go") if err != nil { log.Fatal(err) } defer func() { if err := f.Close(); err != nil { log.Fatal(err) } }() // Upload the file with the default client. API key can be empty. res, err := pixeldrain.Default.File.UploadFile( file.NewUploadFileParamsWithContext(context.Background()).WithFile(f), client.BasicAuth("", "YOUR API KEY IF NECESSARY"), ) if err != nil { log.Fatal(err) } // File ID is used to download the file by this client. fmt.Println("File ID:", swag.StringValue(res.Payload.ID)) // Download URL is for browsers, wget, curl, etc. fmt.Println("Download URL:", pixeldrain.DownloadURL(swag.StringValue(res.Payload.ID)))
Output:
Index ¶
- Variables
- func ContentTypeFixer(upstream runtime.ClientTransport) runtime.ClientTransport
- func DownloadURL(id string) string
- func IsDownloadURL(u string) (bool, error)
- func IsListURL(u string) (bool, error)
- func ListURL(id string) string
- func New(formats strfmt.Registry, cfg *client.TransportConfig) *client.PixeldrainAPI
- type Error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Default = New(nil, nil)
Default is a default client.
Functions ¶
func ContentTypeFixer ¶ added in v0.6.0
func ContentTypeFixer(upstream runtime.ClientTransport) runtime.ClientTransport
ContentTypeFixer returns a new ClientTransport that wraps the given ClientTransport to fix the content type issue.
func DownloadURL ¶ added in v0.6.0
DownloadURL returns the URL associated with the given file ID.
func IsDownloadURL ¶ added in v0.6.0
IsDownloadURL returns true if the given url points a file.
func New ¶ added in v0.5.0
func New(formats strfmt.Registry, cfg *client.TransportConfig) *client.PixeldrainAPI
New creates a new PixelDrain client with the given configurations. formats and cfg can be nil.
Types ¶
type Error ¶ added in v0.5.0
type Error struct {
// contains filtered or unexported fields
}
Error wraps an error to return a more readable error message.
Directories
¶
Path | Synopsis |
---|---|
Package client contains auto generated an open API client for Pixeldrain.
|
Package client contains auto generated an open API client for Pixeldrain. |
file
Package file contains auto generated operations for Pixeldrain file API.
|
Package file contains auto generated operations for Pixeldrain file API. |
list
Package list contains auto generated operations for Pixeldrain list API.
|
Package list contains auto generated operations for Pixeldrain list API. |
cmd
|
|
pd
pd is a Pixeldrain client application.
|
pd is a Pixeldrain client application. |
pd/auth
Package auth provides functions to attach and extract auth information to and from a context.
|
Package auth provides functions to attach and extract auth information to and from a context. |
pd/command
Package command implements subcommands.
|
Package command implements subcommands. |
pd/command/mock
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |
pd/status
Package status defines status codes pd command returns.
|
Package status defines status codes pd command returns. |
Package models contains auto generated structures used in the open API client for Pixeldrain.
|
Package models contains auto generated structures used in the open API client for Pixeldrain. |
Click to show internal directories.
Click to hide internal directories.