Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SniffContentType ¶
SniffContentType 读取前 512 字节,经 net/http.DetectContentType 判定 MIME, 再用 io.MultiReader 拼回,确保不丢数据。仅当 ContentType 为空时调用。
Types ¶
type Format ¶
type Format int
Format 表示渲染目标的格式。
func DetectFormat ¶
DetectFormat 按优先级判定格式:扩展名 > ContentType(可能触发嗅探)> Binary。
func ParseFormat ¶
ParseFormat 将 --as flag 的值解析为 Format。
type Options ¶
type Options struct {
Force bool // 跳过大小限制
MaxImageBytes int64 // 图片最大字节数,超出提示 --force
Width int // 字符画列宽,0=自动探测
}
Options 控制渲染行为。
type Source ¶
type Source struct {
Reader io.ReadCloser
Size int64 // -1 表示未知(S3 无 Content-Length 时)
ContentType string // S3 resp.ContentType / 嗅探结果
Name string // 本地 filepath.Base / S3 s3path.BaseName(key)
IsS3 bool
}
Source 是统一的渲染数据源:来自 S3 对象或本地文件,均暴露 io.ReadCloser。
func OpenSource ¶
func OpenSource(ctx context.Context, arg string, s3c *s3.Client, defaultBucket string) (*Source, error)
OpenSource 按 scheme 分发:s3:// → S3 GetObject 直读(不用 manager.Downloader, 避免 checksum-trailer 与服务端不兼容);否则 → os.Open + os.Stat。 s3c 在本地路径时可为 nil。defaultBucket 在 s3:///key(空桶段)时填充为配置默认桶。
Click to show internal directories.
Click to hide internal directories.