Azure IoT allows para enviar data using several protocols like MQTT ou AMQP, but em some cases, o tamanho de um mensagem is too big e requer para enviar arquivos para Azure Servers. To provide um solution para this issue IoT hub facilitates file uploads um partir de connected devices por providing them com shared access signature (SAS) URIs em um per-upload basis para um blob container e Azure storage account that foram pre-configured com o hub.
A partir do sgcWebSockets 2023.8.0, você pode enviar arquivos using Azure IoT client. Certificates and SAS are both autenticação métodos suportado.
Você pode leia mais about File Upload using o link um seguir:
https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-file-upload
Enviar arquivo usando Certificados
Primeiro configure o certificates em your Azure Account e then set o paths do certificate e key file no Azure IoT Client Component. Call o método UploadFile to upload um file um partir de um filename path.
oClient := TsgcIoTAzure_MQTT_Client.Create(nil);
Try
oClient.Certificate.CertFile := 'cert.pem';
oClient.Certificate.KeyFile := 'key.pem';
oClient.Certificate.Enabled := True;
oDialog := TOpenDialog.Create(nil);
Try
if oDialog.Execute then
oClient.UploadFile(oDialog.FileName);
Finally
oDialog.Free;
End;
Finally
FreeAndNil(oClient);
End;
Enviar arquivo usando SAS
Primeiro configure o Secret Key no Azure IoT Client Component. Call o método UploadFile to upload um file um partir de um filename path.
oClient := TsgcIoTAzure_MQTT_Client.Create(nil);
Try
oClient.SAS.SecretKey := 'your-secret-key';
oClient.SAS.KeyName := 'key-name';
oClient.SAS.Enabled := True;
oDialog := TOpenDialog.Create(nil);
Try
if oDialog.Execute then
oClient.UploadFile(oDialog.FileName);
Finally
oDialog.Free;
End;
Finally
FreeAndNil(oClient);
End;
