Пример #1
0
idigi_status_t app_send_put_request(idigi_handle_t handle)
{
    idigi_status_t status = idigi_no_resource;
    static idigi_data_service_put_request_t header; /* idigi connector will hold this until we get a response/error callback */
    static char const file_path[] = "test/test.txt";
    static char const file_type[] = "text/plain";
    static char const buffer[] = "iDigi data service sample\n";
    client_data_t * const app_data = malloc(sizeof *app_data);

    if (app_data == NULL)
        goto error;

    app_data->data_ptr = buffer;
    app_data->bytes = strlen(buffer);
    header.flags = IDIGI_DATA_PUT_APPEND;
    header.path  = file_path;
    header.content_type = file_type;
    header.context = app_data; /* will be returned in all subsequent callbacks */

    status = idigi_initiate_action(handle, idigi_initiate_data_service, &header, NULL);
    APP_DEBUG("Status: %d, file: %s\n", status, file_path);
    if (status != idigi_success)
        free(app_data);

error:
    return status;
}
idigi_status_t app_send_put_request(idigi_handle_t handle)
{
    idigi_status_t status = idigi_success;
    static idigi_data_service_put_request_t header;
    static char file_path[] = "test/test.txt";
    static char file_type[] = "text/plain";

    header.flags = IDIGI_DATA_PUT_APPEND;
    header.path  = file_path;
    header.content_type = file_type;

    status = idigi_initiate_action(handle, idigi_initiate_data_service, &header, NULL);
    APP_DEBUG("Status: %d, file: %s\n", status, file_path);

    return status;
}