Initializing DIS
The following describes how to use the main function to configure DIS parameters, initialize DIS, set a transmission mode, call upload and download samples, and perform recycling.
int main()
{
int ret = 0;
FILE *logFile = NULL;
//Specify the project ID of the stream.
char *projectId = "c159a24641da49b2a729ea6f57647888";
//Specify the region where the stream is used.
char *region = "******";
//Specify the access address of DIS.
char *host = "dis.cn-north-1.myhuaweicloud.com:20004";
//Specify the stream name.
char *streamName = "lifei_test";
srand((unsigned) time(NULL ));
logFile = fopen("log.txt", "a+");
if(NULL == logFile)
{
printf("open file error\r\n");
return 1;
}
printf("step 1\r\n");
ret = DisInit(logFile, GetUserAuthInfo);
if(0 != ret)
{
printf("init error: %d\r\n", ret);
getchar();
return ret;
}
printf("start test\r\n");
logPrint(1, "this is a test: %d", ret);
.
testSendRecord(streamName);
testGetRecord(streamName);
getchar();
DisDeinit();
return 0;
}
- To initialize DIS, use DisInit(logFile, GetUserAuthInfo).
- To set the serialization mode of data transmission to protobuf, use DISSetSerializedMode("protobuf").
- To set the serialization mode of data transmission to base64, use DISSetSerializedMode("base64").
- To send data, use testSendRecord(streamName).
- To download data, use testGetRecord(streamName).
Last Article: Configuring an AK and SK
Next Article: Creating a Stream Whose Source Data Type Is BLOB, JSON, or CSV
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.