Documentation
¶
Index ¶
- type Client
- func (c *Client) Download(contentID string) (*FileInfo, error)
- func (c *Client) DownloadFromURL(contentURL string) (*FileInfo, error)
- func (c *Client) DownloadFromURLWithOptions(contentURL string, opts *DownloadOptions) (*FileInfo, error)
- func (c *Client) DownloadWithOptions(contentID string, opts *DownloadOptions) (*FileInfo, error)
- type Config
- type DownloadOptions
- type FileInfo
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 is the Contents API client for downloading file attachments. Webex file attachment URLs (returned in Message.Files) point to GET /v1/contents/{contentId} which requires Bearer token auth.
func (*Client) Download ¶
Download fetches a file attachment by its content ID. The contentID is the Webex content identifier (the base64-encoded ID found at the end of URLs like https://webexapis.com/v1/contents/{contentId}).
Automatic retry for file scanning (423):
The SDK automatically retries HTTP 423 (Locked) responses, which Webex returns while a file is being scanned for malware. Retries honour the Retry-After header and are governed by Config.MaxRetries (default 3) and Config.RetryBaseDelay (default 1 s) on the underlying webexsdk.Client. If scanning still hasn't completed after all retries, a structured *webexsdk.APIError with StatusCode 423 is returned.
Other anti-malware responses:
- Returns *webexsdk.APIError with 410 Gone if the file is infected.
- Returns *webexsdk.APIError with 428 Precondition Required if the file is unscannable. Use DownloadWithOptions with AllowUnscannable=true to download such files.
func (*Client) DownloadFromURL ¶
DownloadFromURL fetches a file attachment from a full Webex content URL. This accepts the URLs directly from Message.Files (e.g., "https://webexapis.com/v1/contents/Y2lzY29...").
Automatic retry behaviour and anti-malware semantics are identical to [Download]; see its documentation for details.
func (*Client) DownloadFromURLWithOptions ¶ added in v2.0.14
func (c *Client) DownloadFromURLWithOptions(contentURL string, opts *DownloadOptions) (*FileInfo, error)
DownloadFromURLWithOptions fetches a file from a full URL with configurable options. When opts.AllowUnscannable is true, ?allow=unscannable is appended to bypass the 428 Precondition Required response for unscannable files.
func (*Client) DownloadWithOptions ¶ added in v2.0.14
func (c *Client) DownloadWithOptions(contentID string, opts *DownloadOptions) (*FileInfo, error)
DownloadWithOptions fetches a file attachment with configurable options. When opts.AllowUnscannable is true, ?allow=unscannable is appended to bypass the 428 Precondition Required response for unscannable (e.g., encrypted) files.
type DownloadOptions ¶ added in v2.0.14
type DownloadOptions struct {
// AllowUnscannable when true adds ?allow=unscannable to the request,
// enabling download of files that cannot be scanned for malware
// (e.g., encrypted files). The user assumes all risks.
AllowUnscannable bool
}
DownloadOptions configures file download behavior.
type FileInfo ¶
type FileInfo struct {
// ContentType is the MIME type of the file (e.g., "image/png", "application/pdf").
ContentType string
// ContentDisposition contains the original filename from the server (e.g., "attachment; filename=\"report.pdf\"").
ContentDisposition string
// ContentLength is the size in bytes (-1 if unknown).
ContentLength int64
// Data is the raw file content.
Data []byte
}
FileInfo holds metadata about a downloaded file attachment.