async_fetch_object

package
v7.25.3 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

从指定 URL 抓取资源,并将该资源存储到指定空间中。每次只抓取一个文件,抓取时可以指定保存空间名和最终资源名

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NewFetchTaskInfo

type NewFetchTaskInfo = Response

返回的异步任务信息

type NewFetchTaskParams

type NewFetchTaskParams = Request

要抓取的资源信息

type Request

type Request struct {
	Credentials      credentials.CredentialsProvider // 鉴权参数,用于生成鉴权凭证,如果为空,则使用 HTTPClientOptions 中的 CredentialsProvider
	Url              string                          // 需要抓取的 URL,支持设置多个用于高可用,以’;'分隔,当指定多个 URL 时可以在前一个 URL 抓取失败时重试下一个
	Bucket           string                          // 所在区域的存储空间
	Host             string                          // 从指定 URL 下载数据时使用的 Host
	Key              string                          // 对象名称,如果不传,则默认为文件的哈希值
	Md5              string                          // 文件 MD5,传入以后会在存入存储时对文件做校验,校验失败则不存入指定空间
	Etag             string                          // 对象内容的 ETag,传入以后会在存入存储时对文件做校验,校验失败则不存入指定空间
	CallbackUrl      string                          // 回调 URL
	CallbackBody     string                          // 回调负荷,如果 callback_url 不为空则必须指定
	CallbackBodyType string                          // 回调负荷内容类型,默认为 "application/x-www-form-urlencoded"
	CallbackHost     string                          // 回调时使用的 Host
	FileType         int64                           // 存储文件类型 `0`: 标准存储(默认),`1`: 低频存储,`2`: 归档存储
	IgnoreSameKey    bool                            // 如果空间中已经存在同名文件则放弃本次抓取(仅对比对象名称,不校验文件内容)
}

调用 API 所用的请求

func (*Request) MarshalJSON

func (j *Request) MarshalJSON() ([]byte, error)

func (*Request) UnmarshalJSON

func (j *Request) UnmarshalJSON(data []byte) error

type Response

type Response struct {
	Id               string // 异步任务 ID
	QueuedTasksCount int64  // 当前任务前面的排队任务数量,`0` 表示当前任务正在进行,`-1` 表示任务已经至少被处理过一次(可能会进入重试逻辑)
}

获取 API 所用的响应

func (*Response) MarshalJSON

func (j *Response) MarshalJSON() ([]byte, error)

func (*Response) UnmarshalJSON

func (j *Response) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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