doubao

package
v4.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: AGPL-3.0 Imports: 31 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DirectoryType      = 1
	FileType           = 2
	LinkType           = 3
	ImageType          = 4
	PagesType          = 5
	VideoType          = 6
	AudioType          = 7
	MeetingMinutesType = 8
)
View Source
const (
	BaseURL          = "https://www.doubao.com"
	FileDataType     = "file"
	ImgDataType      = "image"
	VideoDataType    = "video"
	DefaultChunkSize = int64(5 * 1024 * 1024) // 5MB
	MaxRetryAttempts = 3                      // 最大重试次数
	UserAgent        = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
	Region           = "cn-north-1"
	UploadTimeout    = 3 * time.Minute
)

Variables

View Source
var FileNodeType = map[int]string{
	1: "directory",
	2: "file",
	3: "link",
	4: "image",
	5: "pages",
	6: "video",
	7: "audio",
	8: "meeting_minutes",
}

Functions

This section is empty.

Types

type Addition

type Addition struct {
	// Usually one of two
	// driver.RootPath
	driver.RootID
	// define other
	Cookie       string `json:"cookie" type:"text"`
	UploadThread string `json:"upload_thread" default:"3"`
	DownloadApi  string `json:"download_api" type:"select" options:"get_file_url,get_download_info" default:"get_file_url"`
}

type AdvanceOption

type AdvanceOption struct {
	Parallel      int    `json:"Parallel"`
	Stream        int    `json:"Stream"`
	SliceSize     int    `json:"SliceSize"`
	EncryptionKey string `json:"EncryptionKey"`
}

AdvanceOption 高级选项

type AppUserInfo

type AppUserInfo struct {
	BuiAuditInfo string `json:"bui_audit_info"`
}

type AuditInfo

type AuditInfo struct {
}

type BaseResp

type BaseResp struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

type BuiAuditInfo

type BuiAuditInfo struct {
	AuditInfo      AuditInfo `json:"audit_info"`
	IsAuditing     bool      `json:"is_auditing"`
	AuditStatus    int       `json:"audit_status"`
	LastUpdateTime int64     `json:"last_update_time"`
	UnpassReason   string    `json:"unpass_reason"`
	Details        Details   `json:"details"`
}

type CommonResp

type CommonResp struct {
	Code    int             `json:"code"`
	Msg     string          `json:"msg,omitempty"`
	Message string          `json:"message,omitempty"` // 错误情况下的消息
	Data    json.RawMessage `json:"data,omitempty"`    // 原始数据,稍后解析
	Error   *struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
		Locale  string `json:"locale"`
	} `json:"error,omitempty"`
}

func (*CommonResp) GetError

func (r *CommonResp) GetError() error

GetError 获取错误信息

func (*CommonResp) IsSuccess

func (r *CommonResp) IsSuccess() bool

IsSuccess 判断响应是否成功

func (*CommonResp) UnmarshalData

func (r *CommonResp) UnmarshalData(v interface{}) error

UnmarshalData 将data字段解析为指定类型

type Connects

type Connects struct {
	Platform           string `json:"platform"`
	ProfileImageURL    string `json:"profile_image_url"`
	ExpiredTime        int    `json:"expired_time"`
	ExpiresIn          int    `json:"expires_in"`
	PlatformScreenName string `json:"platform_screen_name"`
	UserID             int64  `json:"user_id"`
	PlatformUID        string `json:"platform_uid"`
	SecPlatformUID     string `json:"sec_platform_uid"`
	PlatformAppID      int    `json:"platform_app_id"`
	ModifyTime         int    `json:"modify_time"`
	AccessToken        string `json:"access_token"`
	OpenID             string `json:"open_id"`
}

type Details

type Details struct {
}

type Doubao

type Doubao struct {
	model.Storage
	Addition
	*UploadToken
	UserId string
	// contains filtered or unexported fields
}

func (*Doubao) ArchiveDecompress

func (d *Doubao) ArchiveDecompress(ctx context.Context, srcObj, dstDir model.Obj, args model.ArchiveDecompressArgs) ([]model.Obj, error)

func (*Doubao) Config

func (d *Doubao) Config() driver.Config

func (*Doubao) Copy

func (d *Doubao) Copy(ctx context.Context, srcObj, dstDir model.Obj) (model.Obj, error)

func (*Doubao) Drop

func (d *Doubao) Drop(ctx context.Context) error

func (*Doubao) Extract

func (d *Doubao) Extract(ctx context.Context, obj model.Obj, args model.ArchiveInnerArgs) (*model.Link, error)

func (*Doubao) GetAddition

func (d *Doubao) GetAddition() driver.Additional

func (*Doubao) GetArchiveMeta

func (d *Doubao) GetArchiveMeta(ctx context.Context, obj model.Obj, args model.ArchiveArgs) (model.ArchiveMeta, error)

func (*Doubao) Init

func (d *Doubao) Init(ctx context.Context) error
func (d *Doubao) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error)

func (*Doubao) List

func (d *Doubao) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error)

func (*Doubao) ListArchive

func (d *Doubao) ListArchive(ctx context.Context, obj model.Obj, args model.ArchiveInnerArgs) ([]model.Obj, error)

func (*Doubao) MakeDir

func (d *Doubao) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error

func (*Doubao) Move

func (d *Doubao) Move(ctx context.Context, srcObj, dstDir model.Obj) error

func (*Doubao) Put

func (d *Doubao) Put(ctx context.Context, dstDir model.Obj, file model.FileStreamer, up driver.UpdateProgress) (model.Obj, error)

func (*Doubao) Remove

func (d *Doubao) Remove(ctx context.Context, obj model.Obj) error

func (*Doubao) Rename

func (d *Doubao) Rename(ctx context.Context, srcObj model.Obj, newName string) error

func (*Doubao) Upload

func (d *Doubao) Upload(ctx context.Context, config *UploadConfig, dstDir model.Obj, file model.FileStreamer, up driver.UpdateProgress, dataType string) (model.Obj, error)

Upload 普通上传实现

func (*Doubao) UploadByMultipart

func (d *Doubao) UploadByMultipart(ctx context.Context, config *UploadConfig, fileSize int64, dstDir model.Obj, file model.FileStreamer, up driver.UpdateProgress, dataType string) (model.Obj, error)

UploadByMultipart 分片上传

type FallbackUploadAddress

type FallbackUploadAddress struct {
	StoreInfos   []StoreInfo            `json:"StoreInfos"`
	UploadHosts  []string               `json:"UploadHosts"`
	UploadHeader map[string]interface{} `json:"UploadHeader"`
	SessionKey   string                 `json:"SessionKey"`
	Cloud        string                 `json:"Cloud"`
}

FallbackUploadAddress 备用上传地址

type File

type File struct {
	ID                  string `json:"id"`
	Name                string `json:"name"`
	Key                 string `json:"key"`
	NodeType            int    `json:"node_type"` // 0: 文件, 1: 文件夹
	Size                int64  `json:"size"`
	Source              int    `json:"source"`
	NameReviewStatus    int    `json:"name_review_status"`
	ContentReviewStatus int    `json:"content_review_status"`
	RiskReviewStatus    int    `json:"risk_review_status"`
	ConversationID      string `json:"conversation_id"`
	ParentID            string `json:"parent_id"`
	CreateTime          int64  `json:"create_time"`
	UpdateTime          int64  `json:"update_time"`
}

type GetDownloadInfoResp

type GetDownloadInfoResp struct {
	BaseResp
	Data struct {
		DownloadInfos []struct {
			NodeID    string `json:"node_id"`
			MainURL   string `json:"main_url"`
			BackupURL string `json:"backup_url"`
		} `json:"download_infos"`
	} `json:"data"`
}

type GetFileUrlResp

type GetFileUrlResp struct {
	BaseResp
	Data struct {
		FileUrls []struct {
			URI     string `json:"uri"`
			MainURL string `json:"main_url"`
			BackURL string `json:"back_url"`
		} `json:"file_urls"`
	} `json:"data"`
}

type GetVideoFileUrlResp

type GetVideoFileUrlResp struct {
	BaseResp
	Data struct {
		MediaType string `json:"media_type"`
		MediaInfo []struct {
			Meta struct {
				Height     string  `json:"height"`
				Width      string  `json:"width"`
				Format     string  `json:"format"`
				Duration   float64 `json:"duration"`
				CodecType  string  `json:"codec_type"`
				Definition string  `json:"definition"`
			} `json:"meta"`
			MainURL   string `json:"main_url"`
			BackupURL string `json:"backup_url"`
		} `json:"media_info"`
		OriginalMediaInfo struct {
			Meta struct {
				Height     string  `json:"height"`
				Width      string  `json:"width"`
				Format     string  `json:"format"`
				Duration   float64 `json:"duration"`
				CodecType  string  `json:"codec_type"`
				Definition string  `json:"definition"`
			} `json:"meta"`
			MainURL   string `json:"main_url"`
			BackupURL string `json:"backup_url"`
		} `json:"original_media_info"`
		PosterURL      string `json:"poster_url"`
		PlayableStatus int    `json:"playable_status"`
	} `json:"data"`
}

type InnerUploadAddress

type InnerUploadAddress struct {
	UploadNodes   []UploadNode  `json:"UploadNodes"`
	AdvanceOption AdvanceOption `json:"AdvanceOption"`
}

InnerUploadAddress 内部上传地址

type MediaUploadAuthToken

type MediaUploadAuthToken struct {
	StsToken struct {
		AccessKeyID     string    `json:"access_key_id"`
		SecretAccessKey string    `json:"secret_access_key"`
		SessionToken    string    `json:"session_token"`
		ExpiredTime     time.Time `json:"expired_time"`
		CurrentTime     time.Time `json:"current_time"`
	} `json:"sts_token"`
	UploadInfo struct {
		VideoHost string `json:"video_host"`
		SpaceName string `json:"space_name"`
	} `json:"upload_info"`
}

MediaUploadAuthToken 媒体上传配置

type MediaUploadAuthTokenResp

type MediaUploadAuthTokenResp struct {
	BaseResp
	Data MediaUploadAuthToken `json:"data"`
}

type NodeInfoResp

type NodeInfoResp struct {
	BaseResp
	Data struct {
		NodeInfo   File   `json:"node_info"`
		Children   []File `json:"children"`
		NextCursor string `json:"next_cursor"`
		HasMore    bool   `json:"has_more"`
	} `json:"data"`
}

type Object

type Object struct {
	model.Object
	Key      string
	NodeType int
}

type OperStaffRelationInfo

type OperStaffRelationInfo struct {
	HasPassword               int    `json:"has_password"`
	Mobile                    string `json:"mobile"`
	SecOperStaffUserID        string `json:"sec_oper_staff_user_id"`
	RelationMobileCountryCode int    `json:"relation_mobile_country_code"`
}

type ResponseMetadata

type ResponseMetadata struct {
	RequestID string `json:"RequestId"`
	Action    string `json:"Action"`
	Version   string `json:"Version"`
	Service   string `json:"Service"`
	Region    string `json:"Region"`
	Error     struct {
		CodeN   int    `json:"CodeN,omitempty"`
		Code    string `json:"Code,omitempty"`
		Message string `json:"Message,omitempty"`
	} `json:"Error,omitempty"`
}

type StoreInfo

type StoreInfo struct {
	StoreURI      string                 `json:"StoreUri"`
	Auth          string                 `json:"Auth"`
	UploadID      string                 `json:"UploadID"`
	UploadHeader  map[string]interface{} `json:"UploadHeader,omitempty"`
	StorageHeader map[string]interface{} `json:"StorageHeader,omitempty"`
}

StoreInfo 存储信息

type UploadAddress

type UploadAddress struct {
	StoreInfos   []StoreInfo            `json:"StoreInfos"`
	UploadHosts  []string               `json:"UploadHosts"`
	UploadHeader map[string]interface{} `json:"UploadHeader"`
	SessionKey   string                 `json:"SessionKey"`
	Cloud        string                 `json:"Cloud"`
}

UploadAddress 上传地址信息

type UploadAuthToken

type UploadAuthToken struct {
	ServiceID        string `json:"service_id"`
	UploadPathPrefix string `json:"upload_path_prefix"`
	Auth             struct {
		AccessKeyID     string    `json:"access_key_id"`
		SecretAccessKey string    `json:"secret_access_key"`
		SessionToken    string    `json:"session_token"`
		ExpiredTime     time.Time `json:"expired_time"`
		CurrentTime     time.Time `json:"current_time"`
	} `json:"auth"`
	UploadHost string `json:"upload_host"`
}

UploadAuthToken 多种类型的上传配置:图片/文件

type UploadAuthTokenResp

type UploadAuthTokenResp struct {
	BaseResp
	Data UploadAuthToken `json:"data"`
}

type UploadConfig

type UploadConfig struct {
	UploadAddress         UploadAddress         `json:"UploadAddress"`
	FallbackUploadAddress FallbackUploadAddress `json:"FallbackUploadAddress"`
	InnerUploadAddress    InnerUploadAddress    `json:"InnerUploadAddress"`
	RequestID             string                `json:"RequestId"`
	SDKParam              interface{}           `json:"SDKParam"`
}

type UploadConfigResp

type UploadConfigResp struct {
	ResponseMetadata `json:"ResponseMetadata"`
	Result           UploadConfig `json:"Result"`
}

type UploadNode

type UploadNode struct {
	Vid          string                 `json:"Vid"`
	Vids         []string               `json:"Vids"`
	StoreInfos   []StoreInfo            `json:"StoreInfos"`
	UploadHost   string                 `json:"UploadHost"`
	UploadHeader map[string]interface{} `json:"UploadHeader"`
	Type         string                 `json:"Type"`
	Protocol     string                 `json:"Protocol"`
	SessionKey   string                 `json:"SessionKey"`
	NodeConfig   struct {
		UploadMode string `json:"UploadMode"`
	} `json:"NodeConfig"`
	Cluster string `json:"Cluster"`
}

UploadNode 上传节点信息

type UploadNodeResp

type UploadNodeResp struct {
	BaseResp
	Data struct {
		NodeList []struct {
			LocalID  string `json:"local_id"`
			ID       string `json:"id"`
			ParentID string `json:"parent_id"`
			Name     string `json:"name"`
			Key      string `json:"key"`
			NodeType int    `json:"node_type"` // 0: 文件, 1: 文件夹
		} `json:"node_list"`
	} `json:"data"`
}

type UploadPart

type UploadPart struct {
	UploadId   string `json:"uploadid,omitempty"`
	PartNumber string `json:"part_number,omitempty"`
	Crc32      string `json:"crc32,omitempty"`
	Etag       string `json:"etag,omitempty"`
	Mode       string `json:"mode,omitempty"`
}

UploadPart 上传分片信息

type UploadResp

type UploadResp struct {
	Code       int        `json:"code"`
	ApiVersion string     `json:"apiversion"`
	Message    string     `json:"message"`
	Data       UploadPart `json:"data"`
}

UploadResp 上传响应体

type UploadToken

type UploadToken struct {
	Alice    map[string]UploadAuthToken
	Samantha MediaUploadAuthToken
}

UploadToken 上传令牌配置

type UserInfo

type UserInfo struct {
	AppID                 int                   `json:"app_id"`
	AppUserInfo           AppUserInfo           `json:"app_user_info"`
	AvatarURL             string                `json:"avatar_url"`
	BgImgURL              string                `json:"bg_img_url"`
	BuiAuditInfo          BuiAuditInfo          `json:"bui_audit_info"`
	CanBeFoundByPhone     int                   `json:"can_be_found_by_phone"`
	Connects              []Connects            `json:"connects"`
	CountryCode           int                   `json:"country_code"`
	Description           string                `json:"description"`
	DeviceID              int                   `json:"device_id"`
	Email                 string                `json:"email"`
	EmailCollected        bool                  `json:"email_collected"`
	Gender                int                   `json:"gender"`
	HasPassword           int                   `json:"has_password"`
	HmRegion              int                   `json:"hm_region"`
	IsBlocked             int                   `json:"is_blocked"`
	IsBlocking            int                   `json:"is_blocking"`
	IsRecommendAllowed    int                   `json:"is_recommend_allowed"`
	IsVisitorAccount      bool                  `json:"is_visitor_account"`
	Mobile                string                `json:"mobile"`
	Name                  string                `json:"name"`
	NeedCheckBindStatus   bool                  `json:"need_check_bind_status"`
	OdinUserType          int                   `json:"odin_user_type"`
	OperStaffRelationInfo OperStaffRelationInfo `json:"oper_staff_relation_info"`
	PhoneCollected        bool                  `json:"phone_collected"`
	RecommendHintMessage  string                `json:"recommend_hint_message"`
	ScreenName            string                `json:"screen_name"`
	SecUserID             string                `json:"sec_user_id"`
	SessionKey            string                `json:"session_key"`
	UseHmRegion           bool                  `json:"use_hm_region"`
	UserCreateTime        int64                 `json:"user_create_time"`
	UserID                int64                 `json:"user_id"`
	UserIDStr             string                `json:"user_id_str"`
	UserVerified          bool                  `json:"user_verified"`
	VerifiedContent       string                `json:"verified_content"`
}

type UserInfoResp

type UserInfoResp struct {
	Data    UserInfo `json:"data"`
	Message string   `json:"message"`
}

type VideoCommitUpload

type VideoCommitUpload struct {
	Vid       string `json:"Vid"`
	VideoMeta struct {
		URI          string  `json:"Uri"`
		Height       int     `json:"Height"`
		Width        int     `json:"Width"`
		OriginHeight int     `json:"OriginHeight"`
		OriginWidth  int     `json:"OriginWidth"`
		Duration     float64 `json:"Duration"`
		Bitrate      int     `json:"Bitrate"`
		Md5          string  `json:"Md5"`
		Format       string  `json:"Format"`
		Size         int     `json:"Size"`
		FileType     string  `json:"FileType"`
		Codec        string  `json:"Codec"`
	} `json:"VideoMeta"`
	WorkflowInput struct {
		TemplateID string `json:"TemplateId"`
	} `json:"WorkflowInput"`
	GetPosterMode string `json:"GetPosterMode"`
}

type VideoCommitUploadResp

type VideoCommitUploadResp struct {
	ResponseMetadata ResponseMetadata `json:"ResponseMetadata"`
	Result           struct {
		RequestID string              `json:"RequestId"`
		Results   []VideoCommitUpload `json:"Results"`
	} `json:"Result"`
}

Jump to

Keyboard shortcuts

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