Uploading Streaming Data in JSON Format
Initialize a DIS SDK client instance as instructed in Initializing a DIS SDK Client Instance.
The putRecords_sample.py file provides a code sample. Configure the following parameters in this file:
1 |
streamname ="dis-test1" #Name of an existing stream.
|
records of the putRecords_test method in the putRecords_sample.py file is the data to be uploaded. The data is uploaded in the following format:
1 2 3 4 |
records=[{"data": "abcdefd", "partition_key": "1"}]
#data: data to be uploaded. The value is user-definable; partition_key: partition to which data is written. The value is user-definable.
record1 = {"data": "xxx","partition_key": partition_key}
#You can write multiple pieces of data. The data format is shown in record1. Each time a piece of data is written, the append method is used to transfer the data to the records.
|
After configuring the parameters, run the putRecords_sample.py file to call putRecords_test. The following is an example response:
1 2 |
200
{'failed_record_count': 0, 'records': [{'partition_id': 'shardId-0000000001', 'sequence_number': '15'}]}
|
Last Article: Querying Dump Details
Next Article: Uploading Streaming Data in Protobuf Format
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.