Documentation ¶
Index ¶
- Constants
- func MockFileUploadServer() *httptest.Server
- type Auth
- type ClientOptions
- type ClientWrapper
- type ErrorMessage
- type FileGetList
- type FileGetUser
- type GetUserSubscription
- type ListFile
- type ListsGetUser
- type PixelDrainClient
- func (pd *PixelDrainClient) CreateList(r *RequestCreateList) (*ResponseCreateList, error)
- func (pd *PixelDrainClient) Delete(r *RequestDelete) (*ResponseDelete, error)
- func (pd *PixelDrainClient) Download(r *RequestDownload) (*ResponseDownload, error)
- func (pd *PixelDrainClient) DownloadThumbnail(r *RequestThumbnail) (*ResponseThumbnail, error)
- func (pd *PixelDrainClient) GetFileInfo(r *RequestFileInfo) (*ResponseFileInfo, error)
- func (pd *PixelDrainClient) GetList(r *RequestGetList) (*ResponseGetList, error)
- func (pd *PixelDrainClient) GetUser(r *RequestGetUser) (*ResponseGetUser, error)
- func (pd *PixelDrainClient) GetUserFiles(r *RequestGetUserFiles) (*ResponseGetUserFiles, error)
- func (pd *PixelDrainClient) GetUserLists(r *RequestGetUserLists) (*ResponseGetUserLists, error)
- func (pd *PixelDrainClient) SetUploadCallback(callback func(info req.UploadInfo))
- func (pd *PixelDrainClient) UploadPOST(r *RequestUpload) (*ResponseUpload, error)
- func (pd *PixelDrainClient) UploadPUT(r *RequestUpload) (*ResponseUpload, error)
- type RequestCreateList
- type RequestDelete
- type RequestDownload
- type RequestFileInfo
- type RequestGetList
- type RequestGetUser
- type RequestGetUserFiles
- type RequestGetUserLists
- type RequestThumbnail
- type RequestUpload
- type ResponseCreateList
- type ResponseDefault
- type ResponseDelete
- type ResponseDownload
- type ResponseFileInfo
- type ResponseGetList
- type ResponseGetUser
- type ResponseGetUserFiles
- type ResponseGetUserLists
- type ResponseThumbnail
- type ResponseUpload
Constants ¶
const ( Name = "PixelDrain.com" BaseURL = "https://pixeldrain.com/" APIURL = BaseURL + "api" DefaultUserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36" // errors ErrMissingPathToFile = "file path or file reader is required" ErrMissingFileID = "file id is required" ErrMissingFilename = "if you use ReadCloser you need to specify the filename" )
Variables ¶
This section is empty.
Functions ¶
func MockFileUploadServer ¶
Types ¶
type Auth ¶
type Auth struct {
APIKey string // if you have an account you can enter here your API Key for uploading in your account
}
Auth hold the auth information
func (*Auth) IsAuthAvailable ¶
IsAuthAvailable checks if an API Key available
type ClientOptions ¶
type ClientWrapper ¶ added in v1.5.0
type ClientWrapper struct { Client *req.Client UploadCallback func(info req.UploadInfo) }
type ErrorMessage ¶ added in v1.5.0
type FileGetList ¶
type FileGetList struct { DetailHref string `json:"detail_href"` Description string `json:"description"` Success bool `json:"success"` ID string `json:"id"` Name string `json:"name"` Size int64 `json:"size"` DateCreated time.Time `json:"date_created"` DateLastView time.Time `json:"date_last_view"` MimeType string `json:"mime_type"` Views int64 `json:"views"` BandwidthUsed int64 `json:"bandwidth_used"` ThumbnailHref string `json:"thumbnail_href"` }
type FileGetUser ¶
type FileGetUser struct { ID string `json:"id"` Name string `json:"name"` Size int64 `json:"size"` Views int64 `json:"views"` BandwidthUsed int64 `json:"bandwidth_used"` BandwidthUsedPaid int64 `json:"bandwidth_used_paid"` Downloads int64 `json:"downloads"` DateUpload time.Time `json:"date_upload"` DateLastView time.Time `json:"date_last_view"` MimeType string `json:"mime_type"` ThumbnailHref string `json:"thumbnail_href"` HashSha256 string `json:"hash_sha256"` Availability string `json:"availability"` AvailabilityMessage string `json:"availability_message"` AbuseType string `json:"abuse_type"` AbuseReporterName string `json:"abuse_reporter_name"` CanEdit bool `json:"can_edit"` ShowAds bool `json:"show_ads"` AllowVideoPlayer bool `json:"allow_video_player"` DownloadSpeedLimit int64 `json:"download_speed_limit"` }
type GetUserSubscription ¶ added in v1.3.0
type GetUserSubscription struct { ID string `json:"id"` Name string `json:"name"` Type string `json:"type"` FileSizeLimit int64 `json:"file_size_limit"` FileExpiryDays int64 `json:"file_expiry_days"` StorageSpace int64 `json:"storage_space"` PricePerTbStorage int64 `json:"price_per_tb_storage"` PricePerTbBandwidth int64 `json:"price_per_tb_bandwidth"` MonthlyTransferCap int64 `json:"monthly_transfer_cap"` FileViewerBranding bool `json:"file_viewer_branding"` }
type ListsGetUser ¶
type PixelDrainClient ¶
type PixelDrainClient struct { Client *ClientWrapper Debug bool }
func New ¶
func New(opt *ClientOptions, c *ClientWrapper) *PixelDrainClient
New - create a new PixelDrainClient
func (*PixelDrainClient) CreateList ¶
func (pd *PixelDrainClient) CreateList(r *RequestCreateList) (*ResponseCreateList, error)
CreateList POST /api/list
func (*PixelDrainClient) Delete ¶
func (pd *PixelDrainClient) Delete(r *RequestDelete) (*ResponseDelete, error)
Delete DELETE /api/file/{id}
func (*PixelDrainClient) Download ¶
func (pd *PixelDrainClient) Download(r *RequestDownload) (*ResponseDownload, error)
Download GET /api/file/{id}
func (*PixelDrainClient) DownloadThumbnail ¶
func (pd *PixelDrainClient) DownloadThumbnail(r *RequestThumbnail) (*ResponseThumbnail, error)
DownloadThumbnail GET /api/file/{id}/thumbnail?width=x&height=x
func (*PixelDrainClient) GetFileInfo ¶
func (pd *PixelDrainClient) GetFileInfo(r *RequestFileInfo) (*ResponseFileInfo, error)
GetFileInfo GET /api/file/{id}/info
func (*PixelDrainClient) GetList ¶
func (pd *PixelDrainClient) GetList(r *RequestGetList) (*ResponseGetList, error)
GetList GET /api/list/{id}
func (*PixelDrainClient) GetUser ¶ added in v1.3.0
func (pd *PixelDrainClient) GetUser(r *RequestGetUser) (*ResponseGetUser, error)
GetUser GET /api/user
func (*PixelDrainClient) GetUserFiles ¶
func (pd *PixelDrainClient) GetUserFiles(r *RequestGetUserFiles) (*ResponseGetUserFiles, error)
GetUserFiles GET /api/user/files
func (*PixelDrainClient) GetUserLists ¶
func (pd *PixelDrainClient) GetUserLists(r *RequestGetUserLists) (*ResponseGetUserLists, error)
GetUserLists GET /api/user/lists
func (*PixelDrainClient) SetUploadCallback ¶ added in v1.5.0
func (pd *PixelDrainClient) SetUploadCallback(callback func(info req.UploadInfo))
func (*PixelDrainClient) UploadPOST ¶
func (pd *PixelDrainClient) UploadPOST(r *RequestUpload) (*ResponseUpload, error)
UploadPOST POST /api/file curl -X POST -i -H "Authorization: Basic <TOKEN>" -F "file=@cat.jpg" https://pixeldrain.com/api/file
func (*PixelDrainClient) UploadPUT ¶
func (pd *PixelDrainClient) UploadPUT(r *RequestUpload) (*ResponseUpload, error)
UploadPUT PUT /api/file/{name} curl -X PUT -i -H "Authorization: Basic <TOKEN>" --upload-file cat.jpg https://pixeldrain.com/api/file/test_cat.jpg
type RequestCreateList ¶
type RequestCreateList struct { Title string `json:"title"` Anonymous bool `json:"anonymous"` Files []ListFile `json:"files"` Auth Auth URL string }
RequestCreateList parameters for creating new list
type RequestDelete ¶
RequestDelete delete the file if you are the owner with the given ID
type RequestDownload ¶
type RequestDownload struct { ID string PathToSave string Auth Auth URL string // specific the API endpoint, is set by default with the correct values }
RequestDownload container for the file download
type RequestFileInfo ¶
RequestFileInfo the FileInfo request needs only an ID
type RequestGetList ¶
RequestGetList request to a retrieve a list
type RequestGetUser ¶ added in v1.3.0
RequestGetUser ...
type RequestGetUserFiles ¶
RequestGetUserFiles ...
type RequestGetUserLists ¶
RequestGetUserLists ...
type RequestThumbnail ¶
type RequestThumbnail struct { ID string Width string Height string PathToSave string Auth Auth URL string }
RequestThumbnail the Thumbnail request needs the ID and width and height
type RequestUpload ¶
type RequestUpload struct { File io.ReadCloser PathToFile string // path to the file "/home/user/cat.jpg" FileName string // just the filename "test.jpg" Anonymous bool // if the upload is anonymous or with auth Auth Auth URL string // specific the upload endpoint, is set by default with the correct values }
RequestUpload container for the upload information
func (*RequestUpload) GetFileName ¶
func (r *RequestUpload) GetFileName() string
GetFileName return the filename from the path if no specific filename in the params
type ResponseCreateList ¶
type ResponseCreateList struct { ID string `json:"id"` ResponseDefault }
type ResponseDefault ¶
type ResponseDelete ¶
type ResponseDelete struct {
ResponseDefault
}
type ResponseDownload ¶
type ResponseDownload struct { FilePath string `json:"file_path"` FileName string `json:"file_name"` FileSize int64 `json:"file_size"` ResponseDefault }
type ResponseFileInfo ¶
type ResponseFileInfo struct { ID string `json:"id"` Name string `json:"name"` Size int64 `json:"size"` Views int64 `json:"views"` BandwidthUsed int64 `json:"bandwidth_used"` BandwidthUsedPaid int64 `json:"bandwidth_used_paid"` Downloads int64 `json:"downloads"` DateUpload time.Time `json:"date_upload"` DateLastView time.Time `json:"date_last_view"` MimeType string `json:"mime_type"` ThumbnailHref string `json:"thumbnail_href"` HashSha256 string `json:"hash_sha256"` CanEdit bool `json:"can_edit"` ResponseDefault }
type ResponseGetList ¶
type ResponseGetList struct { ID string `json:"id"` Title string `json:"title"` DateCreated time.Time `json:"date_created"` Files []FileGetList `json:"files"` ResponseDefault }
type ResponseGetUser ¶ added in v1.3.0
type ResponseGetUser struct { Username string `json:"username"` Email string `json:"email"` Subscription GetUserSubscription `json:"subscription"` StorageSpaceUsed int64 `json:"storage_space_used"` IsAdmin bool `json:"is_admin"` BalanceMicroEur int64 `json:"balance_micro_eur"` HotlinkingEnabled bool `json:"hotlinking_enabled"` MonthlyTransferCap int64 `json:"monthly_transfer_cap"` MonthlyTransferUsed int64 `json:"monthly_transfer_used"` FileViewerBranding interface{} `json:"file_viewer_branding"` FileEmbedDomains string `json:"file_embed_domains"` SkipFileViewer bool `json:"skip_file_viewer"` ResponseDefault }
type ResponseGetUserFiles ¶
type ResponseGetUserFiles struct { Files []FileGetUser `json:"files"` ResponseDefault }
type ResponseGetUserLists ¶
type ResponseGetUserLists struct { Lists []ListsGetUser `json:"lists"` ResponseDefault }
type ResponseThumbnail ¶
type ResponseThumbnail struct { FilePath string `json:"file_path"` FileName string `json:"file_name"` FileSize int64 `json:"file_size"` ResponseDefault }
type ResponseUpload ¶
type ResponseUpload struct { ID string `json:"id,omitempty"` ResponseDefault }
func (*ResponseUpload) GetFileURL ¶
func (rsp *ResponseUpload) GetFileURL() string
GetFileURL return the full URl to the uploaded file