Download Task Operations
Updated at:2025-11-03
Create download task
Use the following code to create a download task.
Go
1createDownloadTaskRequest := CreateDownloadTaskRequest{
2 Name: "sdk-download-task-test",
3 Project: "default",
4 LogStoreName: "test",
5 LogStreamName: "",
6 Query: "match *",
7 QueryStartTime: time.Now().Add(-10 * time.Minute).UTC().Format("2006-01-02T15:04:05Z"),
8 QueryEndTime: time.Now().UTC().Format("2006-01-02T15:04:05Z"),
9 Format: "json",
10 Limit: 100,
11 Order: "desc",
12 FileDir: "",
13}
14uuid, err := BLS_CLIENT.CreateDownloadTask(createDownloadTaskRequest)
15if err != nil {
16 fmt.Println("Create downlaod task failed: %v", err)
17} else {
18 fmt.Printf('Create download task success with uuid: %s\n', uuid)
19}
Prompt:
- Detailed parameter configuration and restrictions may refer to BLS API document CreateDownloadTask
Obtain the specified download task
With following codes, obtain the download task details of the specified UUID
Go
1describeDownloadRequest := DescribeDownloadRequest{
2 UUID: uuid,
3}
4dt, err := BLS_CLIENT.DescribeDownloadTask(describeDownloadRequest)
5if err != nil {
6 fmt.Println("Get download task failed: %v", err)
7} else {
8 fmt.Printf("get download task info: %v\n", dt)
9}
Prompt:
- Detailed parameter configuration and restrictions may refer to BLS API document Describe Download Task
Obtain the download link
With following codes, obtain the logstore data file link generated by the download task, and download the file through this link
Go
1getDownloadTaskLinkRequest := GetDownloadTaskLinkRequest{
2 UUID: uuid,
3}
4lr, err := BLS_CLIENT.GetDownloadTaskLink(getDownloadTaskLinkRequest)
5if err != nil {
6 fmt.Println("get download task link failed: %v", err)
7} else {
8 fmt.Printf("get download task link success with %v\n", lr)
9}
Prompt:
- Detailed parameter configuration and restrictions may refer to BLS API document Get Download Task Link
Get download task list
Use the following code to retrieve the list of download tasks created by the current user.
Go
1//Optional parameter list
2listDownloadTaskRequest := ListDownloadTaskRequest{
3 Project: "default",
4 LogStoreName: "test",
5 Order: "desc",
6 OrderBy: "",
7 PageNo: 1,
8 PageSize: 20,
9}
10res, err := BLS_CLIENT.ListDownloadTask(listDownloadTaskRequest)
11if err != nil {
12 fmt.Println("List download task failed: %v", err)
13} else {
14 fmt.Printf("Download task list: %v\n", res)
15}
Prompt:
- Detailed parameter configuration and restrictions may refer to BLS API document List Download Task
Delete download task
Use the following code to delete the download task specified by the UUID.
Go
1deleteDownloadTaskRequest := DeleteDownloadTaskRequest{
2 UUID: uuid,
3}
4err = BLS_CLIENT.DeleteDownloadTask(deleteDownloadTaskRequest)
5if err != nil {
6 fmt.Println("Delete download task failed: %v", err)
7} else {
8 fmt.Println("Delete download task success.")
9}
Prompt:
- Detailed parameter configuration and restrictions may refer to BLS API document Delete Download Task
