media

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package media provides helpers for uploading media to Twitter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FinalizeResponse

type FinalizeResponse struct {
	MediaID          int64           `json:"media_id"`
	MediaIDString    string          `json:"media_id_string"`
	Size             int64           `json:"size"`
	ExpiresAfterSecs int             `json:"expires_after_secs,omitempty"`
	ProcessingInfo   *ProcessingInfo `json:"processing_info,omitempty"`
}

FinalizeResponse captures the response from the FINALIZE phase.

type InitResponse

type InitResponse struct {
	MediaID          int64  `json:"media_id"`
	MediaIDString    string `json:"media_id_string"`
	ExpiresAfterSecs int    `json:"expires_after_secs,omitempty"`
}

InitResponse captures the response from the INIT phase.

type MediaCategory

type MediaCategory string

MediaCategory represents the type of media being uploaded.

const (
	CategoryTweetImage MediaCategory = "tweet_image"
	CategoryTweetVideo MediaCategory = "tweet_video"
	CategoryTweetGif   MediaCategory = "tweet_gif"
	CategoryDMImage    MediaCategory = "dm_image"
	CategoryDMVideo    MediaCategory = "dm_video"
	CategoryDMGif      MediaCategory = "dm_gif"
)

type ProcessingError

type ProcessingError struct {
	Code    int    `json:"code"`
	Name    string `json:"name"`
	Message string `json:"message"`
}

ProcessingError captures async processing errors.

type ProcessingInfo

type ProcessingInfo struct {
	State           string           `json:"state"`
	CheckAfterSecs  int              `json:"check_after_secs,omitempty"`
	ProgressPercent int              `json:"progress_percent,omitempty"`
	Error           *ProcessingError `json:"error,omitempty"`
}

ProcessingInfo contains async processing status for videos.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service coordinates Twitter media upload operations.

func NewService

func NewService(bearerToken string) *Service

NewService constructs a Service with the provided bearer token.

func (*Service) UploadFile

func (s *Service) UploadFile(ctx context.Context, filePath string, category MediaCategory) (string, error)

UploadFile uploads a media file using the chunked upload flow. For large files or videos, this uses INIT -> APPEND -> FINALIZE. For small images, it may use simple upload.

type StatusResponse

type StatusResponse struct {
	MediaID        int64           `json:"media_id"`
	MediaIDString  string          `json:"media_id_string"`
	ProcessingInfo *ProcessingInfo `json:"processing_info,omitempty"`
}

StatusResponse captures the response from the STATUS endpoint.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL