0

I want to upload a file to Azure It hub. I achieved it using Azure SDK. But my program to upload file is custom development which can be prone to bugs. I want to use well established CURL utility to upload as we do not have any other business logic involved.

I come to know that Azure fully supports rest for device to cloud communication. I have seen examples of sending messages to cloud using CURL.

How can I upload a file using CURL?

Vipul
  • 1,563
  • 4
  • 22
  • 46

1 Answers1

0

Based on the doc Upload files with IoT Hub this upload process is divided into 3 steps via the REST API calls. More details about these steps can be found here.

To your question such as how to upload a file using the CURL via Azure IoT Hub, it will necessary to convert these steps to the curl commands.

The following is an example of the first step such as a getting a reference info for uploading file:

curl -d "{\"blobName\":\"test.json\"}" -H "Content-Type: application/json" -H "Authorization: SharedAccessSignature sr=xxxxx.azure-devices.net&sig=xxxx&skn=iothubowner" -X POST https://xxxxx.azure-devices.net/devices/myDeviceId/files?api-version=2018-06-30

Note, that the steps 1. and 3. require a sas token for Azure IoT Hub Authorization.

Roman Kiss
  • 7,925
  • 1
  • 8
  • 21