You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Create a [getFileUploadNotificationReceiver](/java/api/com.microsoft.azure.sdk.iot.service.fileuploadnotificationreceiver) object.
127
+
* Use [open](/java/api/com.microsoft.azure.sdk.iot.service.fileuploadnotificationreceiver?#com-microsoft-azure-sdk-iot-service-fileuploadnotificationreceiver-open()) to connect to IoT Hub.
128
+
* Call [receive](/java/api/com.microsoft.azure.sdk.iot.service.fileuploadnotificationreceiver?#com-microsoft-azure-sdk-iot-service-fileuploadnotificationreceiver-receive()) to check for the file upload status. This method returns a [fileUploadNotification](/java/api/com.microsoft.azure.sdk.iot.service.fileuploadnotification?view=azure-java-stable) object. If an upload notice is received, you can view upload status fields using [fileUploadNotification](/java/api/com.microsoft.azure.sdk.iot.service.fileuploadnotification) methods.
Copy file name to clipboardExpand all lines: includes/iot-hub-howto-file-upload-node.md
+54-1Lines changed: 54 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,8 @@ const path = require('path');
42
42
43
43
Use [getBlobSharedAccessSignature](/javascript/api/azure-iot-device/client?#azure-iot-device-client-getblobsharedaccesssignature) to get the linked storage account SAS Token from IoT Hub.
44
44
45
+
For example:
46
+
45
47
```javascript
46
48
// make sure you set these environment variables prior to running the sample.
@@ -58,7 +60,7 @@ throw new errors.ArgumentError('Invalid upload parameters');
58
60
59
61
To upload a file to IoT Hub:
60
62
61
-
1.Creates a communication pipeline.
63
+
1.Create a stream pipeline.
62
64
2. Constructs the blob URL.
63
65
3. Create a [BlockBlobClient](/javascript/api/@azure/storage-blob/blockblobclient) for file upload to Blob Storage.
64
66
4. Call [uploadFile](/javascript/api/@azure/storage-blob/blockblobclient?#@azure-storage-blob-blockblobclient-uploadfile) to upload the file to Blob Storage.
You can create a separate application to check the IoT Hub service client for device file upload notifications.
122
+
123
+
### Connect to the IoT Hub service client
124
+
125
+
Create the [Client](/javascript/api/azure-iothub/client) using [fromConnectionString](/javascript/api/azure-iothub/client?#azure-iothub-client-fromconnectionstring).
*[Open](/javascript/api/azure-iothub/client?view=azure-node-latest#azure-iothub-client-open-1) the connection to IoT Hub
137
+
* Call [getFileNotificationReceiver](/javascript/api/azure-iothub/client?#azure-iothub-client-getfilenotificationreceiver). Supply the name of a file upload callback method that will be called when notification messages are received.
138
+
* Process file upload notifications in the callback method.
115
139
140
+
This example sets up a `receiveFileUploadNotification` notification callback receiver. The receiver interprets the file upload status information and prints a status messsage to the console.
141
+
142
+
```javascript
143
+
//Open the connection to IoT hub
144
+
serviceClient.open(function (err) {
145
+
if (err) {
146
+
console.error('Could not connect: '+err.message);
147
+
} else {
148
+
console.log('Service client connected');
149
+
//Set up the receiveFileUploadNotification notification message callback receiver
0 commit comments