Microsoft Azure IoTHub client libraries

Dependents:   sht15_remote_monitoring RobotArmDemo iothub_client_sample_amqp f767zi_mqtt ... more

This library implements the Microsoft Azure IoTHub client library. The code is replicated from https://github.com/Azure/azure-iot-sdks

Revision:
77:e4e36df9caee
Parent:
75:86205ca63a59
Child:
79:bb88037c05e6
--- a/iothub_client_ll_uploadtoblob.c	Mon Sep 25 13:37:53 2017 -0700
+++ b/iothub_client_ll_uploadtoblob.c	Sat Oct 21 20:11:49 2017 +0000
@@ -15,6 +15,7 @@
 #include "azure_c_shared_utility/tickcounter.h"
 #include "azure_c_shared_utility/httpapiexsas.h"
 #include "azure_c_shared_utility/shared_util_options.h"
+#include "azure_c_shared_utility/urlencode.h"
 
 #include "iothub_client_ll.h"
 #include "iothub_client_options.h"
@@ -517,23 +518,38 @@
                                                                         }
                                                                         else
                                                                         {
-                                                                            if (!(
-                                                                                (STRING_concat(sasUri, json_hostName) == 0) &&
-                                                                                (STRING_concat(sasUri, "/") == 0) &&
-                                                                                (STRING_concat(sasUri, json_containerName) == 0) &&
-                                                                                (STRING_concat(sasUri, "/") == 0) &&
-                                                                                (STRING_concat(sasUri, json_blobName) == 0) &&
-                                                                                (STRING_concat(sasUri, json_sasToken) == 0)
-                                                                                ))
-                                                                            {
-                                                                                /*Codes_SRS_IOTHUBCLIENT_LL_02_082: [ If extracting and saving the correlationId or SasUri fails then IoTHubClient_LL_UploadToBlob shall fail and return IOTHUB_CLIENT_ERROR. ]*/
-                                                                                LogError("unable to STRING_concat");
-                                                                                result = __FAILURE__;
-                                                                            }
-                                                                            else
-                                                                            {
-                                                                                result = 0; /*success in step 1*/
-                                                                            }
+                                                                            /*Codes_SRS_IOTHUBCLIENT_LL_32_008: [ The returned file name shall be URL encoded before passing back to the cloud. ]*/
+                                                                            STRING_HANDLE fileName = URL_EncodeString(json_blobName);
+																			
+																			if (fileName == NULL)
+																			{
+                                                                                /*Codes_SRS_IOTHUBCLIENT_LL_32_009: [ If URL_EncodeString fails then IoTHubClient_LL_UploadToBlob shall fail and return IOTHUB_CLIENT_ERROR. ]*/
+																				LogError("unable to URL_EncodeString of filename");
+																				result = __FAILURE__;
+																			}
+
+                                                                            else 
+																			{
+																				if (!(
+																					(STRING_concat(sasUri, json_hostName) == 0) &&
+																					(STRING_concat(sasUri, "/") == 0) &&
+																					(STRING_concat(sasUri, json_containerName) == 0) &&
+																					(STRING_concat(sasUri, "/") == 0) &&
+																					(STRING_concat(sasUri, STRING_c_str(fileName)) == 0) &&
+																					(STRING_concat(sasUri, json_sasToken) == 0)
+																					))
+																				{
+																					/*Codes_SRS_IOTHUBCLIENT_LL_02_082: [ If extracting and saving the correlationId or SasUri fails then IoTHubClient_LL_UploadToBlob shall fail and return IOTHUB_CLIENT_ERROR. ]*/
+																					LogError("unable to STRING_concat");
+																					result = __FAILURE__;
+																				}
+																				else
+																				{
+																					result = 0; /*success in step 1*/
+																				}
+																				
+																				STRING_delete(fileName);
+																			}	
                                                                         }
                                                                     }
                                                                 }