Get Download Status

Get the status of a file download task.

Prerequisites

A file download task is already created.

Request Format

GET https://{apigw-address}/data-federation/v2.0/channels/read/{channelId}/download/{taskId}/status

Request Parameters (URI)

Name

Location (Path/Query)

Mandatory/Optional

Data Type

Description

orgId

Query

Mandatory

String

The organization ID. How to get the orgId>>

channelId

Path

Mandatory

String

Channel ID.

taskId

Path

Mandatory

String

ID of the file download task.

Response Parameters

Name

Data Type

Description

data

List<JSONObject>

Return the status information of the download task. See Status Struct

Status Struct

Name

Data Type

Description

taskId

String

ID of the file download task.

downloadUrl

String

URL for downloading the file.

progressCode

Integer

Status code of the file download task (0: waiting; 1: running; 2: failed; 3: success; 4: cancelling; 5: cancelled; 6: deleting; 7: deleted).

progressDesc

String

Description of the status code.

Samples

Request Sample

url: https://{apigw-address}/data-federation/v2.0/channels/read/{channelId}/download/{taskId}/status?orgId={}

method: GET

Return Sample

{
    "code": 0,
    "msg": "OK",
    "data": {
        "taskId": "79449f27d3ff44b3990c547360c2851f",
        "downloadUrl": "http://data-query-proxy.beta-k8s-cn4.eniot.io/channels/read/ch-dee0c5/download/79449f27d3ff44b3990c547360c2851f/data?orgId=o15504722874071",
        "progressDesc": "success",
        "progressCode": "3"
    }
}

Java SDK Sample

import com.alibaba.fastjson.JSONObject;
import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envision.apim.poseidon.request.PoseidonRequest;
import com.google.common.net.HttpHeaders;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Sample {

    private static String accessKey = "AccessKey of your APP";
    private static String secretKey = "SecretKey of your APP";
    private static String orgId = "yourOrgId";
    private static String chId = "yourChannelId";
    private static String taskId = "yourTaskId";
    private static String url = "https://{domain_url}";

    private static class Request extends PoseidonRequest {

        public void setQueryParam(String key, Object value) {
            queryEncodeParams().put(key, value);
        }

        public void setMethod(String method) {
            this.method = method;
        }

        public void setBodyParams(String key, Object value) {
            bodyParams().put(key, value);
        }

        private String method;

        @Override
        public String baseUri() {
            return "";
        }

        @Override
        public String method() {
            return method;
        }
    }

    @Test
    public void downloadStatus() {
        Request request = new Request();
        request.setQueryParam("orgId", orgId);
        request.setMethod("GET");
        try {
            JSONObject response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey))
                    .url(url + "/data-federation/v2.0/channels/read/" + chId + "/download/" + taskId + "/status")
                    .getResponse(request, JSONObject.class);
            System.out.println(response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}