upload file to blobstorage via azure-iothub without sdk

2020-11-06T14:53:44.453+00:00

Hi, I want to upload a file to an azure-blob-storage through an azure-iot-hub account withour using the azure SDK. As stated in this docs (https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-file-upload), i have first created a blobstorage account and i have associated it to the iothub account. Then, i was able to perform a post request to {iot hub}.azure-devices.net/devices/{deviceId}/files and received the correct answer with a Sas Token.
Here is where i´m stucked, as in the docs it is recommended to use the azure SDK, which i want to avoid.
I have done a HTTP PUT directly to the blob storage with the provided Sas-Token (as described here https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob), but i failed. I think i am not constructing well the header, but i don´t know really.
Here is an example of the header:

PUT /<STORAGE-CONTAINER>/<DEVICE ID>/prueba1.txt?<SAS TOKEN HERE> HTTP/1.1
Host: <BLOB STORAGE>
Content-Type: multipart/form-data; boundary=---------------------------735323031399963166993862150
Content-Length: 206

-----------------------------
735323031399963166993862150
Content-Disposition: form-data; name="prueba1-name"; filename="prueba1.txt"

viva peron

-----------------------------
735323031399963166993862150

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,542 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,143 questions
0 comments No comments
{count} votes

Accepted answer
  1. deherman-MSFT 34,436 Reputation points Microsoft Employee
    2020-11-06T21:23:07.43+00:00

    @CAGNACCI, YAGO (Servicio Externo en YPF)

    I believe the issue maybe that your are missing the closing two hyphens after your boundary name. -----------------------------735323031399963166993862150-- You might find this thread helpful. Also I don't believe filename is necessary in your Content-Disposition.

    Please give this a try and let me know if you see any errors.

    -------------------------------

    Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

0 additional answers

Sort by: Most helpful