Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
iothub_client/inc/blob.h@0:f7f1f0d76dd6, 2018-08-23 (annotated)
- Committer:
- XinZhangMS
- Date:
- Thu Aug 23 06:52:14 2018 +0000
- Revision:
- 0:f7f1f0d76dd6
azure-c-sdk for mbed os supporting NUCLEO_F767ZI
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| XinZhangMS | 0:f7f1f0d76dd6 | 1 | // Copyright (c) Microsoft. All rights reserved. |
| XinZhangMS | 0:f7f1f0d76dd6 | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| XinZhangMS | 0:f7f1f0d76dd6 | 3 | |
| XinZhangMS | 0:f7f1f0d76dd6 | 4 | /** @file blob.h |
| XinZhangMS | 0:f7f1f0d76dd6 | 5 | * @brief Contains blob APIs needed for File Upload feature of IoTHub client. |
| XinZhangMS | 0:f7f1f0d76dd6 | 6 | * |
| XinZhangMS | 0:f7f1f0d76dd6 | 7 | * @details IoTHub client needs to upload a byte array by using blob storage API |
| XinZhangMS | 0:f7f1f0d76dd6 | 8 | * IoTHub service provides the complete SAS URI to execute a PUT request |
| XinZhangMS | 0:f7f1f0d76dd6 | 9 | * that will upload the data. |
| XinZhangMS | 0:f7f1f0d76dd6 | 10 | * |
| XinZhangMS | 0:f7f1f0d76dd6 | 11 | */ |
| XinZhangMS | 0:f7f1f0d76dd6 | 12 | |
| XinZhangMS | 0:f7f1f0d76dd6 | 13 | #ifndef BLOB_H |
| XinZhangMS | 0:f7f1f0d76dd6 | 14 | #define BLOB_H |
| XinZhangMS | 0:f7f1f0d76dd6 | 15 | |
| XinZhangMS | 0:f7f1f0d76dd6 | 16 | #include "../../c-utility/inc/azure_c_shared_utility/macro_utils.h" |
| XinZhangMS | 0:f7f1f0d76dd6 | 17 | #include "../../c-utility/inc/azure_c_shared_utility/buffer_.h" |
| XinZhangMS | 0:f7f1f0d76dd6 | 18 | #include "../../c-utility/inc/azure_c_shared_utility/strings_types.h" |
| XinZhangMS | 0:f7f1f0d76dd6 | 19 | #include "../../c-utility/inc/azure_c_shared_utility/httpapiex.h" |
| XinZhangMS | 0:f7f1f0d76dd6 | 20 | #include "iothub_client_core_ll.h" |
| XinZhangMS | 0:f7f1f0d76dd6 | 21 | #include "../../c-utility/inc/azure_c_shared_utility/shared_util_options.h" |
| XinZhangMS | 0:f7f1f0d76dd6 | 22 | #include "iothub_client_ll.h" |
| XinZhangMS | 0:f7f1f0d76dd6 | 23 | |
| XinZhangMS | 0:f7f1f0d76dd6 | 24 | #ifdef __cplusplus |
| XinZhangMS | 0:f7f1f0d76dd6 | 25 | |
| XinZhangMS | 0:f7f1f0d76dd6 | 26 | #include <cstddef> |
| XinZhangMS | 0:f7f1f0d76dd6 | 27 | extern "C" |
| XinZhangMS | 0:f7f1f0d76dd6 | 28 | { |
| XinZhangMS | 0:f7f1f0d76dd6 | 29 | #else |
| XinZhangMS | 0:f7f1f0d76dd6 | 30 | #include <stddef.h> |
| XinZhangMS | 0:f7f1f0d76dd6 | 31 | #endif |
| XinZhangMS | 0:f7f1f0d76dd6 | 32 | |
| XinZhangMS | 0:f7f1f0d76dd6 | 33 | #include "../../c-utility/inc/azure_c_shared_utility/umock_c_prod.h" |
| XinZhangMS | 0:f7f1f0d76dd6 | 34 | |
| XinZhangMS | 0:f7f1f0d76dd6 | 35 | /* Allow unit tests to override MAX_BLOCK_COUNT to something much smaller */ |
| XinZhangMS | 0:f7f1f0d76dd6 | 36 | #ifndef MAX_BLOCK_COUNT |
| XinZhangMS | 0:f7f1f0d76dd6 | 37 | /* Maximum count of blocks uploaded is 50000, per server*/ |
| XinZhangMS | 0:f7f1f0d76dd6 | 38 | #define MAX_BLOCK_COUNT 50000 |
| XinZhangMS | 0:f7f1f0d76dd6 | 39 | #endif |
| XinZhangMS | 0:f7f1f0d76dd6 | 40 | |
| XinZhangMS | 0:f7f1f0d76dd6 | 41 | #define BLOB_RESULT_VALUES \ |
| XinZhangMS | 0:f7f1f0d76dd6 | 42 | BLOB_OK, \ |
| XinZhangMS | 0:f7f1f0d76dd6 | 43 | BLOB_ERROR, \ |
| XinZhangMS | 0:f7f1f0d76dd6 | 44 | BLOB_NOT_IMPLEMENTED, \ |
| XinZhangMS | 0:f7f1f0d76dd6 | 45 | BLOB_HTTP_ERROR, \ |
| XinZhangMS | 0:f7f1f0d76dd6 | 46 | BLOB_INVALID_ARG, \ |
| XinZhangMS | 0:f7f1f0d76dd6 | 47 | BLOB_ABORTED |
| XinZhangMS | 0:f7f1f0d76dd6 | 48 | |
| XinZhangMS | 0:f7f1f0d76dd6 | 49 | DEFINE_ENUM(BLOB_RESULT, BLOB_RESULT_VALUES) |
| XinZhangMS | 0:f7f1f0d76dd6 | 50 | |
| XinZhangMS | 0:f7f1f0d76dd6 | 51 | /** |
| XinZhangMS | 0:f7f1f0d76dd6 | 52 | * @brief Synchronously uploads a byte array to blob storage |
| XinZhangMS | 0:f7f1f0d76dd6 | 53 | * |
| XinZhangMS | 0:f7f1f0d76dd6 | 54 | * @param SASURI The URI to use to upload data |
| XinZhangMS | 0:f7f1f0d76dd6 | 55 | * @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. |
| XinZhangMS | 0:f7f1f0d76dd6 | 56 | * @param context Any data provided by the user to serve as context on getDataCallback. |
| XinZhangMS | 0:f7f1f0d76dd6 | 57 | * @param httpStatus A pointer to an out argument receiving the HTTP status (available only when the return value is BLOB_OK) |
| XinZhangMS | 0:f7f1f0d76dd6 | 58 | * @param httpResponse A BUFFER_HANDLE that receives the HTTP response from the server (available only when the return value is BLOB_OK) |
| XinZhangMS | 0:f7f1f0d76dd6 | 59 | * @param certificates A null terminated string containing CA certificates to be used |
| XinZhangMS | 0:f7f1f0d76dd6 | 60 | * @param proxyOptions A structure that contains optional web proxy information |
| XinZhangMS | 0:f7f1f0d76dd6 | 61 | * |
| XinZhangMS | 0:f7f1f0d76dd6 | 62 | * @return A @c BLOB_RESULT. BLOB_OK means the blob has been uploaded successfully. Any other value indicates an error |
| XinZhangMS | 0:f7f1f0d76dd6 | 63 | */ |
| XinZhangMS | 0:f7f1f0d76dd6 | 64 | MOCKABLE_FUNCTION(, BLOB_RESULT, Blob_UploadMultipleBlocksFromSasUri, const char*, SASURI, IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK, getDataCallback, void*, context, unsigned int*, httpStatus, BUFFER_HANDLE, httpResponse, const char*, certificates, HTTP_PROXY_OPTIONS*, proxyOptions) |
| XinZhangMS | 0:f7f1f0d76dd6 | 65 | |
| XinZhangMS | 0:f7f1f0d76dd6 | 66 | /** |
| XinZhangMS | 0:f7f1f0d76dd6 | 67 | * @brief Synchronously uploads a byte array as a new block to blob storage |
| XinZhangMS | 0:f7f1f0d76dd6 | 68 | * |
| XinZhangMS | 0:f7f1f0d76dd6 | 69 | * @param requestContent The data to upload |
| XinZhangMS | 0:f7f1f0d76dd6 | 70 | * @param blockId The block id (from 00000 to 49999) |
| XinZhangMS | 0:f7f1f0d76dd6 | 71 | * @param xml The XML file containing the blockId list |
| XinZhangMS | 0:f7f1f0d76dd6 | 72 | * @param relativePath The destination path within the storage |
| XinZhangMS | 0:f7f1f0d76dd6 | 73 | * @param httpApiExHandle The connection handle |
| XinZhangMS | 0:f7f1f0d76dd6 | 74 | * @param httpStatus A pointer to an out argument receiving the HTTP status (available only when the return value is BLOB_OK) |
| XinZhangMS | 0:f7f1f0d76dd6 | 75 | * @param httpResponse A BUFFER_HANDLE that receives the HTTP response from the server (available only when the return value is BLOB_OK) |
| XinZhangMS | 0:f7f1f0d76dd6 | 76 | */ |
| XinZhangMS | 0:f7f1f0d76dd6 | 77 | //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) |
| XinZhangMS | 0:f7f1f0d76dd6 | 78 | 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) |
| XinZhangMS | 0:f7f1f0d76dd6 | 79 | #ifdef __cplusplus |
| XinZhangMS | 0:f7f1f0d76dd6 | 80 | } |
| XinZhangMS | 0:f7f1f0d76dd6 | 81 | #endif |
| XinZhangMS | 0:f7f1f0d76dd6 | 82 | |
| XinZhangMS | 0:f7f1f0d76dd6 | 83 | #endif /* BLOB_H */ |