Create Download Request

Create a file download task.

Prerequisites

A read channel for downloading files is already started and running, and the channel must have the cross-source analysis function disabled. For more information, see Downloading Files.

Request Format

POST https://{apigw-address}/data-federation/v2.0/channels/read/{channelId}/download-request

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.

Request Parameters (Body)

Name

Mandatory/Optional

Data Type

Description

taskName

Mandatory

String

Specify the name of the file download task.

sourceName

Mandatory

String

Specify the data source alias (currently supporting HIVE(EnOS) data source).

querySql

Mandatory

String

Specify the SQL statement for downloading files.

filePackageName

Mandatory

String

Specify name of the downloaded file.

files

Optional

List<JSONObject>

Configuration of the downloaded file. For details, see File Configuration Struct

callbackURL

Optional

String

Call back the downlaod result with POST method. For details of the response parameters, see Download Task Callback Request Struct

selfDefineQueuePara

Optional

String

Specify Hive downloading task parameters, separated by ;.

File Configuration Struct

Name

Mandatory/Optional

Data Type

Description

split

Mandatory

Boolean

Specify whether to enable partition for the downloaded file (true: enable partition; false: disable partition).

encoding

Mandatory

String

Specify the file encoding method (options are utf-8 and gbk).

delimiter

String

Boolean

Specify the field delimiter (options are \t, ,, and ;).

fileHeader

Mandatory

List<String>

Specify the file table header, separated by ,.

fileRename

Optional

List<JSONObject>

When enabling partition for the downloaded file, specify file part names. For details, see File Rename Struct

File Rename Struct

Name

Mandatory/Optional

Data Type

Description

file1

Mandatory

String

Specify the file part name.

file2

Mandatory

String

Specify the file part name.

file3

Mandatory

String

Specify the file part name.

Response Parameters

Name

Data Type

Description

data

List<JSONObject>

Return the information of downloaded file, see Task ID Struct

Task ID

Name

Data Type

Description

taskId

String

ID of the created file download task.

Samples

Request Sample

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

method: POST

request body:

{
  "taskName": "test_federation_download_openapi",
  "sourceName": "hive_enos"
  "querySql": "select * from students",
  "filePackageName": "studentsOpenAPI",
  "callbackURL":"http://localhost:8080",
  "selfDefineQueuePara":"set mapreduce.map.memory.mb=1024;set mapreduce.reduce.memory.mb=2048",
  "files": {
    "split": true,
    "encoding": "utf-8",
    "delimiter": ",",
    "fileHeader": [
      "c1",
      "c2",
      "c3",
      "c4",
      "c5",
      "c6"
    ],
    "fileRename": {
      "1": "group1",
      "2": "group2",
      "3": "group3",
      "4": "group4"
    }
  }
}

Return Sample

{
  "msg": "OK",
  "code": 0,
  "data": {
    "taskId": "3049d82e949e47958246ff0136a77fba"
  }
}

SDK Samples


You can access the SDK samples for data federation service on GitHub: