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