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
internal/blob.h@88:248736be106e, 2018-06-11 (annotated)
- Committer:
- AzureIoTClient
- Date:
- Mon Jun 11 15:39:23 2018 -0700
- Revision:
- 88:248736be106e
- Child:
- 92:97148cf9aa2a
1.2.5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AzureIoTClient | 88:248736be106e | 1 | // Copyright (c) Microsoft. All rights reserved. |
AzureIoTClient | 88:248736be106e | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
AzureIoTClient | 88:248736be106e | 3 | |
AzureIoTClient | 88:248736be106e | 4 | /** @file blob.h |
AzureIoTClient | 88:248736be106e | 5 | * @brief Contains blob APIs needed for File Upload feature of IoTHub client. |
AzureIoTClient | 88:248736be106e | 6 | * |
AzureIoTClient | 88:248736be106e | 7 | * @details IoTHub client needs to upload a byte array by using blob storage API |
AzureIoTClient | 88:248736be106e | 8 | * IoTHub service provides the complete SAS URI to execute a PUT request |
AzureIoTClient | 88:248736be106e | 9 | * that will upload the data. |
AzureIoTClient | 88:248736be106e | 10 | * |
AzureIoTClient | 88:248736be106e | 11 | */ |
AzureIoTClient | 88:248736be106e | 12 | |
AzureIoTClient | 88:248736be106e | 13 | #ifndef BLOB_H |
AzureIoTClient | 88:248736be106e | 14 | #define BLOB_H |
AzureIoTClient | 88:248736be106e | 15 | |
AzureIoTClient | 88:248736be106e | 16 | #include "azure_c_shared_utility/macro_utils.h" |
AzureIoTClient | 88:248736be106e | 17 | #include "azure_c_shared_utility/buffer_.h" |
AzureIoTClient | 88:248736be106e | 18 | #include "azure_c_shared_utility/strings_types.h" |
AzureIoTClient | 88:248736be106e | 19 | #include "azure_c_shared_utility/httpapiex.h" |
AzureIoTClient | 88:248736be106e | 20 | #include "iothub_client_core_ll.h" |
AzureIoTClient | 88:248736be106e | 21 | #include "azure_c_shared_utility/shared_util_options.h" |
AzureIoTClient | 88:248736be106e | 22 | |
AzureIoTClient | 88:248736be106e | 23 | #ifdef __cplusplus |
AzureIoTClient | 88:248736be106e | 24 | #include <cstddef> |
AzureIoTClient | 88:248736be106e | 25 | extern "C" |
AzureIoTClient | 88:248736be106e | 26 | { |
AzureIoTClient | 88:248736be106e | 27 | #else |
AzureIoTClient | 88:248736be106e | 28 | #include <stddef.h> |
AzureIoTClient | 88:248736be106e | 29 | #endif |
AzureIoTClient | 88:248736be106e | 30 | |
AzureIoTClient | 88:248736be106e | 31 | #include "azure_c_shared_utility/umock_c_prod.h" |
AzureIoTClient | 88:248736be106e | 32 | |
AzureIoTClient | 88:248736be106e | 33 | /* Allow unit tests to override MAX_BLOCK_COUNT to something much smaller */ |
AzureIoTClient | 88:248736be106e | 34 | #ifndef MAX_BLOCK_COUNT |
AzureIoTClient | 88:248736be106e | 35 | /* Maximum count of blocks uploaded is 50000, per server*/ |
AzureIoTClient | 88:248736be106e | 36 | #define MAX_BLOCK_COUNT 50000 |
AzureIoTClient | 88:248736be106e | 37 | #endif |
AzureIoTClient | 88:248736be106e | 38 | |
AzureIoTClient | 88:248736be106e | 39 | #define BLOB_RESULT_VALUES \ |
AzureIoTClient | 88:248736be106e | 40 | BLOB_OK, \ |
AzureIoTClient | 88:248736be106e | 41 | BLOB_ERROR, \ |
AzureIoTClient | 88:248736be106e | 42 | BLOB_NOT_IMPLEMENTED, \ |
AzureIoTClient | 88:248736be106e | 43 | BLOB_HTTP_ERROR, \ |
AzureIoTClient | 88:248736be106e | 44 | BLOB_INVALID_ARG, \ |
AzureIoTClient | 88:248736be106e | 45 | BLOB_ABORTED |
AzureIoTClient | 88:248736be106e | 46 | |
AzureIoTClient | 88:248736be106e | 47 | DEFINE_ENUM(BLOB_RESULT, BLOB_RESULT_VALUES) |
AzureIoTClient | 88:248736be106e | 48 | |
AzureIoTClient | 88:248736be106e | 49 | /** |
AzureIoTClient | 88:248736be106e | 50 | * @brief Synchronously uploads a byte array to blob storage |
AzureIoTClient | 88:248736be106e | 51 | * |
AzureIoTClient | 88:248736be106e | 52 | * @param SASURI The URI to use to upload data |
AzureIoTClient | 88:248736be106e | 53 | * @param getDataCallbackEx A callback to be invoked to acquire the file chunks to be uploaded, as well as to indicate the status of the upload of the previous block. |
AzureIoTClient | 88:248736be106e | 54 | * @param context Any data provided by the user to serve as context on getDataCallback. |
AzureIoTClient | 88:248736be106e | 55 | * @param httpStatus A pointer to an out argument receiving the HTTP status (available only when the return value is BLOB_OK) |
AzureIoTClient | 88:248736be106e | 56 | * @param httpResponse A BUFFER_HANDLE that receives the HTTP response from the server (available only when the return value is BLOB_OK) |
AzureIoTClient | 88:248736be106e | 57 | * @param certificates A null terminated string containing CA certificates to be used |
AzureIoTClient | 88:248736be106e | 58 | * @param proxyOptions A structure that contains optional web proxy information |
AzureIoTClient | 88:248736be106e | 59 | * |
AzureIoTClient | 88:248736be106e | 60 | * @return A @c BLOB_RESULT. BLOB_OK means the blob has been uploaded successfully. Any other value indicates an error |
AzureIoTClient | 88:248736be106e | 61 | */ |
AzureIoTClient | 88:248736be106e | 62 | MOCKABLE_FUNCTION(, BLOB_RESULT, Blob_UploadMultipleBlocksFromSasUri, const char*, SASURI, IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX, getDataCallbackEx, void*, context, unsigned int*, httpStatus, BUFFER_HANDLE, httpResponse, const char*, certificates, HTTP_PROXY_OPTIONS*, proxyOptions) |
AzureIoTClient | 88:248736be106e | 63 | |
AzureIoTClient | 88:248736be106e | 64 | /** |
AzureIoTClient | 88:248736be106e | 65 | * @brief Synchronously uploads a byte array as a new block to blob storage |
AzureIoTClient | 88:248736be106e | 66 | * |
AzureIoTClient | 88:248736be106e | 67 | * @param requestContent The data to upload |
AzureIoTClient | 88:248736be106e | 68 | * @param blockId The block id (from 00000 to 49999) |
AzureIoTClient | 88:248736be106e | 69 | * @param xml The XML file containing the blockId list |
AzureIoTClient | 88:248736be106e | 70 | * @param relativePath The destination path within the storage |
AzureIoTClient | 88:248736be106e | 71 | * @param httpApiExHandle The connection handle |
AzureIoTClient | 88:248736be106e | 72 | * @param httpStatus A pointer to an out argument receiving the HTTP status (available only when the return value is BLOB_OK) |
AzureIoTClient | 88:248736be106e | 73 | * @param httpResponse A BUFFER_HANDLE that receives the HTTP response from the server (available only when the return value is BLOB_OK) |
AzureIoTClient | 88:248736be106e | 74 | */ |
AzureIoTClient | 88:248736be106e | 75 | //MOCKABLE_FUNCTION(, BLOB_RESULT, Blob_UploadNextBlock, BUFFER_HANDLE, requestContent, unsigned int, blockID, STRING_HANDLE, xml, const char*, relativePath, HTTPAPIEX_HANDLE, httpApiExHandle, unsigned int*, httpStatus, BUFFER_HANDLE, httpResponse) |
AzureIoTClient | 88:248736be106e | 76 | MOCKABLE_FUNCTION(, BLOB_RESULT, Blob_UploadBlock, HTTPAPIEX_HANDLE, httpApiExHandle, const char*, relativePath, BUFFER_HANDLE, requestContent, unsigned int, blockID, STRING_HANDLE, blockIDList, unsigned int*, httpStatus, BUFFER_HANDLE, httpResponse) |
AzureIoTClient | 88:248736be106e | 77 | #ifdef __cplusplus |
AzureIoTClient | 88:248736be106e | 78 | } |
AzureIoTClient | 88:248736be106e | 79 | #endif |
AzureIoTClient | 88:248736be106e | 80 | |
AzureIoTClient | 88:248736be106e | 81 | #endif /* BLOB_H */ |