FileUpload Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.device.fileupload.FileUpload

public final class FileUpload

Provide means to upload file in the Azure Storage using the IoTHub.

Constructor Summary

Constructor Description
FileUpload(DeviceClientConfig config)

CONSTRUCTOR

Method Summary

Modifier and Type Method and Description
void closeNow()

Close the file upload cancelling all existing uploads and shutting down the thread pool.

synchronized void uploadToBlobAsync(String blobName, InputStream inputStream, long streamLength, IotHubEventCallback statusCallback, Object statusCallbackContext)

Upload the file to container, which was associated to the iothub.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

FileUpload

public FileUpload(DeviceClientConfig config)

CONSTRUCTOR

Parameters:

config - is the set of device client configurations.

Throws:

java.lang.IllegalArgumentException - if one of the parameters is null.
java.io.IOException - if one of the parameters is null.

Method Details

closeNow

public void closeNow()

Close the file upload cancelling all existing uploads and shutting down the thread pool.

Throws:

java.io.IOException - if an I/O error occurs in the inputStream.

uploadToBlobAsync

public synchronized void uploadToBlobAsync(String blobName, InputStream inputStream, long streamLength, IotHubEventCallback statusCallback, Object statusCallbackContext)

Upload the file to container, which was associated to the iothub. This function will start the upload process, and back the execution to the caller. The upload process will be executed in background. When it is completed, the background thread will trigger the callback with the upload status.

Parameters:

blobName - is the name of the file in the container.
inputStream - is the input stream.
streamLength - is the stream length.
statusCallback - is the callback to notify that the upload is completed (with status).
statusCallbackContext - is the context of the callback, allowing multiple uploads in parallel.

Throws:

java.lang.IllegalArgumentException - if one of the parameters is invalid. blobName is null or empty, inputStream is null or not available, streamLength is negative, statusCallback is null
java.io.IOException - if one of the parameters is invalid. blobName is null or empty, inputStream is null or not available, streamLength is negative, statusCallback is null

Applies to