Azure / azure-iot-sdk-c

A C99 SDK for connecting devices to Microsoft Azure IoT services
https://azure.github.io/azure-iot-sdk-c
Other
587 stars 739 forks source link

Need support for upload file to Blob on iOS #605

Closed LeePepe closed 5 years ago

LeePepe commented 6 years ago

Using AzureIoTHubClient (1.2.4) Using AzureIoTUtility (1.1.4) Using AzureIoTuAmqp (1.2.4) Using AzureIoTuMqtt (1.1.4)

Description of the issue:

I want to upload a file to Azure Iot Hub Blob. And I found the API:

IoTHubClient_LL_UploadToBlob But when I only do that, it will report a Error:

Code sample exhibiting the issue:

There is my code. data is iOS Data struct and it may be a image or a audio.

let source = UnsafePointer<UInt8>((data as NSData).bytes.assumingMemoryBound(to: UInt8.self))

if (IoTHubClient_LL_UploadToBlob(iotHubClientHandle, "iOS/\(filename)", source, data.count)) != IOTHUB_CLIENT_OK {
    print("failed to upload \(filename)")
} else {
    print("success to upload \(filename)")
}

Console log of the issue:

Info: unknown option CURLOPT_VERBOSE
Error: Time:Tue Aug 21 10:37:38 2018 File:/Users/ltp1994/Development/azure-iot-samples-ios/quickstart/sample-device/Pods/AzureIoTUtility/src/httpapiex.c Func:HTTPAPIEX_SetOption Line:609 error code = HTTPAPIEX_INVALID_ARG
Info: Waiting for TLS connection
Info: Waiting for TLS connection
Info: Waiting for TLS connection
Error: Time:Tue Aug 21 10:40:49 2018 File:/Users/ltp1994/Development/azure-iot-samples-ios/quickstart/sample-device/Pods/AzureIoTHubClient/iothub_client/src/iothub_client_ll_uploadtoblob.c Func:IoTHubClient_LL_UploadToBlob_step1and2 Line:417 HTTP code was 400
Error: Time:Tue Aug 21 10:41:01 2018 File:/Users/ltp1994/Development/azure-iot-samples-ios/quickstart/sample-device/Pods/AzureIoTHubClient/iothub_client/src/iothub_client_ll_uploadtoblob.c Func:IoTHubClient_LL_UploadMultipleBlocksToBlob_Impl Line:940 error in IoTHubClient_LL_UploadToBlob_step1
failed to upload iOSImageTest2.png
ewertons commented 6 years ago

Hi @LeePepe ,

have you tried running just the sample in your machine, using the same connection string you have used above?

If not, please do so and let us know if it works.

Other than that, have your code ever succeeded uploading to blob, or this is the only result you ever got? What is the size of the data (data.count) you are trying to upload?

yzhong94 commented 5 years ago

@LeePepe have you tried this again to see if this works?

yzhong94 commented 5 years ago

Closing due to inactivity - upload to blob is supported on iOS.

az-iot-builder-01 commented 5 years ago

@LeePepe, @ewertons, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey