0

What is the maximum size of a file uploaded through IoT Hub? Is it 256KB like the maximum message size (according to documentation)

Loreno
  • 668
  • 8
  • 26

1 Answers1

2

You're uploading to blob storage if you're using the File Upload functionality in the IoT Hub Device SDK .

Current size limit of a block blob is 4.75 TiB.

Sample code:

private static async void SendToBlobAsync()
{
    string fileName = "image.jpg";
    Console.WriteLine("Uploading file: {0}", fileName);
    var watch = System.Diagnostics.Stopwatch.StartNew();

    using (var sourceData = new FileStream(@"image.jpg", FileMode.Open))
    {
        await deviceClient.UploadToBlobAsync(fileName, sourceData);
    }

    watch.Stop();
    Console.WriteLine("Time to upload file: {0}ms\n", watch.ElapsedMilliseconds);
}

deviceClient is your IoT Hub client (device).

evilSnobu
  • 24,582
  • 8
  • 41
  • 71
  • Thanks! Is it counted as just 1 message in IoTHub? Or no message at all? – Loreno Mar 21 '19 at 10:32
  • 1
    Good question. The [file upload notification][https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notifications] definitely counts toward the message quota, not sure about the `.UploadToBlobAsync()`. Test it out, create a new hub with just one device and point a simulated device to it, do an upload and check counters. – evilSnobu Mar 21 '19 at 10:53
  • 1
    If you do decide to do that test please report back findings, we should make a pull request into the IoT Hub documentation since i believe this is key information that may help many others. – evilSnobu Mar 21 '19 at 11:17
  • I'll do and I'll post here – Loreno Mar 21 '19 at 11:25
  • 2
    It should count as 2 messages. How the File Upload works: The DeviceClient sends a message to IoT Hub requesting a storage URL including a SAS token (1 message). IoT Hub sends down the requested URL and token. Now the DeviceClient will do the upload directly against the Blob storage. IoT Hub is not involved in this part. Once the upload is done, DeviceClient sends the second message, the File Upload notification ("hey, I'm done uploading") to IoT Hub. – silent Mar 21 '19 at 11:56
  • 1
    @silent Looks like you're right. I created new IoT Hub - strange thing is that initially it already had 3 messages count, even though I didn't even create any devices. Then I created a simple file uploader and run it. Now I see 5 messages - so 2 were added. – Loreno Mar 21 '19 at 12:01