Documentation
¶
Index ¶
- Constants
- Variables
- func ExecuteMediaStatus(mediaID, authType, username string, verbose, wait, trace bool, ...) error
- func ExecuteMediaUpload(filePath, mediaType, mediaCategory, authType, username string, ...) error
- func ExecuteRequest(options RequestOptions, client Client) error
- func ExecuteStreamRequest(options RequestOptions, client Client) error
- func ExtractCommand(url string) string
- func ExtractMediaID(url string) string
- func ExtractSegmentIndex(data string) string
- func HandleMediaAppendRequest(options RequestOptions, mediaFile string, client Client) (json.RawMessage, error)
- func HandleRequest(options RequestOptions, forceStream bool, mediaFile string, client Client) error
- func IsMediaAppendRequest(url string, mediaFile string) bool
- func IsStreamingEndpoint(endpoint string) bool
- type ApiClient
- func (c *ApiClient) BuildMultipartRequest(options MultipartOptions) (*http.Request, error)
- func (c *ApiClient) BuildRequest(requestOptions RequestOptions) (*http.Request, error)
- func (c *ApiClient) SendMultipartRequest(options MultipartOptions) (json.RawMessage, error)
- func (c *ApiClient) SendRequest(options RequestOptions) (json.RawMessage, error)
- func (c *ApiClient) StreamRequest(options RequestOptions) error
- type Client
- type InitRequest
- type MediaUploader
- func (m *MediaUploader) Append() error
- func (m *MediaUploader) CheckStatus() (json.RawMessage, error)
- func (m *MediaUploader) Finalize() (json.RawMessage, error)
- func (m *MediaUploader) GetMediaID() string
- func (m *MediaUploader) Init(mediaType string, mediaCategory string) error
- func (m *MediaUploader) SetMediaID(mediaID string)
- func (m *MediaUploader) WaitForProcessing() (json.RawMessage, error)
- type MultipartOptions
- type RequestOptions
Constants ¶
const (
// MediaEndpoint is the endpoint for media uploads
MediaEndpoint = "/2/media/upload"
)
Variables ¶
var StreamingEndpoints = map[string]bool{ "/2/tweets/search/stream": true, "/2/tweets/sample/stream": true, "/2/tweets/sample10/stream": true, "/2/tweets/firehose/stream": true, "/2/tweets/firehose/stream/lang/en": true, "/2/tweets/firehose/stream/lang/ja": true, "/2/tweets/firehose/stream/lang/ko": true, "/2/tweets/firehose/stream/lang/pt": true, }
StreamingEndpoints is a map of endpoint prefixes that should be streamed
Functions ¶
func ExecuteMediaStatus ¶
func ExecuteMediaStatus(mediaID, authType, username string, verbose, wait, trace bool, headers []string, client Client) error
ExecuteMediaStatus handles the media status command execution
func ExecuteMediaUpload ¶
func ExecuteMediaUpload(filePath, mediaType, mediaCategory, authType, username string, verbose, waitForProcessing, trace bool, headers []string, client Client) error
ExecuteMediaUpload handles the media upload command execution
func ExecuteRequest ¶
func ExecuteRequest(options RequestOptions, client Client) error
ExecuteRequest handles the execution of a regular API request
func ExecuteStreamRequest ¶
func ExecuteStreamRequest(options RequestOptions, client Client) error
ExecuteStreamRequest handles the execution of a streaming API request
func ExtractMediaID ¶
ExtractMediaID extracts media_id from URL or data
func ExtractSegmentIndex ¶
ExtractSegmentIndex extracts segment_index from URL or data
func HandleMediaAppendRequest ¶
func HandleMediaAppendRequest(options RequestOptions, mediaFile string, client Client) (json.RawMessage, error)
HandleMediaAppendRequest handles a media append request with a file
func HandleRequest ¶
func HandleRequest(options RequestOptions, forceStream bool, mediaFile string, client Client) error
HandleRequest determines the type of request and executes it accordingly
func IsMediaAppendRequest ¶
IsMediaAppendRequest checks if the request is a media append request
func IsStreamingEndpoint ¶
IsStreamingEndpoint checks if an endpoint should be streamed
Types ¶
type ApiClient ¶
type ApiClient struct {
// contains filtered or unexported fields
}
ApiClient handles API requests
func NewApiClient ¶
NewApiClient creates a new ApiClient
func (*ApiClient) BuildMultipartRequest ¶
func (c *ApiClient) BuildMultipartRequest(options MultipartOptions) (*http.Request, error)
BuildMultipartRequest builds an HTTP request with multipart form data
func (*ApiClient) BuildRequest ¶
func (c *ApiClient) BuildRequest(requestOptions RequestOptions) (*http.Request, error)
BuildRequest builds an HTTP request
func (*ApiClient) SendMultipartRequest ¶
func (c *ApiClient) SendMultipartRequest(options MultipartOptions) (json.RawMessage, error)
SendMultipartRequest sends an HTTP request with multipart form data
func (*ApiClient) SendRequest ¶
func (c *ApiClient) SendRequest(options RequestOptions) (json.RawMessage, error)
SendRequest sends an HTTP request
func (*ApiClient) StreamRequest ¶
func (c *ApiClient) StreamRequest(options RequestOptions) error
StreamRequest sends an HTTP request and streams the response
type Client ¶
type Client interface {
BuildRequest(requestOptions RequestOptions) (*http.Request, error)
BuildMultipartRequest(options MultipartOptions) (*http.Request, error)
SendRequest(options RequestOptions) (json.RawMessage, error)
StreamRequest(options RequestOptions) error
SendMultipartRequest(options MultipartOptions) (json.RawMessage, error)
}
Client is an interface for API clients
type InitRequest ¶
type MediaUploader ¶
type MediaUploader struct {
// contains filtered or unexported fields
}
MediaUploader handles media upload operations
func NewMediaUploader ¶
func NewMediaUploader(client Client, filePath string, verbose, trace bool, authType string, username string, headers []string) (*MediaUploader, error)
NewMediaUploader creates a new MediaUploader
func (*MediaUploader) Append ¶
func (m *MediaUploader) Append() error
Append uploads the media in chunks
func (*MediaUploader) CheckStatus ¶
func (m *MediaUploader) CheckStatus() (json.RawMessage, error)
CheckStatus checks the status of the media upload
func (*MediaUploader) Finalize ¶
func (m *MediaUploader) Finalize() (json.RawMessage, error)
Finalize finalizes the media upload
func (*MediaUploader) GetMediaID ¶
func (m *MediaUploader) GetMediaID() string
GetMediaID returns the media ID
func (*MediaUploader) Init ¶
func (m *MediaUploader) Init(mediaType string, mediaCategory string) error
Init initializes the media upload
func (*MediaUploader) SetMediaID ¶
func (m *MediaUploader) SetMediaID(mediaID string)
SetMediaID sets the media ID
func (*MediaUploader) WaitForProcessing ¶
func (m *MediaUploader) WaitForProcessing() (json.RawMessage, error)
WaitForProcessing waits for media processing to complete
type MultipartOptions ¶
type MultipartOptions struct {
RequestOptions
FormFields map[string]string
FileField string
FilePath string
FileName string
FileData []byte
}
MultipartOptions contains options specific to multipart requests