Azure IoT Hub Client - How to upload files in application/json format
up vote
0
down vote
favorite
I have Azure IoT Hub Python. Trying to upload the files through this routine
def iothub_file_upload_sample_run():
try:
print ( "IoT Hub file upload sample, press Ctrl-C to exit" )
client = IoTHubClient(CONNECTION_STRING, PROTOCOL)
f = open(PATHTOFILE, "r")
content = f.read()
client.upload_blob_async(FILENAME, content, len(content), blob_upload_conf_callback)
print ( "" )
print ( "File upload initiated..." )
This works fine but the files content types are "application/octet-stream"
I went to some posts and tried by adding "client.set_options('auto_url_encode_decode', True)" as below
def iothub_file_upload_sample_run():
try:
print ( "IoT Hub file upload sample, press Ctrl-C to exit" )
client = IoTHubClient(CONNECTION_STRING, PROTOCOL)
client.set_options('auto_url_encode_decode', True)
f = open(PATHTOFILE, "r")
content = f.read()
client.upload_blob_async(FILENAME, content, len(content), blob_upload_conf_callback)
print ( "" )
print ( "File upload initiated..." )
But the response message is
File:C:Releaseiot-sdks-
internalsreleasepythonautomationaziotsdk_pytoolssrccc-
utilityadaptershttpapi_winhttp.c Func:HTTPAPI_CloneOption Line:1046
unknown option auto_url_encode_decode
unknown option auto_url_encode_decode and Protocol is HTTP
Not sure if this is limitation of Azure IoT Hub Python to default send Application/octet-stream
Any pointers would be appreciated
add a comment |
up vote
0
down vote
favorite
I have Azure IoT Hub Python. Trying to upload the files through this routine
def iothub_file_upload_sample_run():
try:
print ( "IoT Hub file upload sample, press Ctrl-C to exit" )
client = IoTHubClient(CONNECTION_STRING, PROTOCOL)
f = open(PATHTOFILE, "r")
content = f.read()
client.upload_blob_async(FILENAME, content, len(content), blob_upload_conf_callback)
print ( "" )
print ( "File upload initiated..." )
This works fine but the files content types are "application/octet-stream"
I went to some posts and tried by adding "client.set_options('auto_url_encode_decode', True)" as below
def iothub_file_upload_sample_run():
try:
print ( "IoT Hub file upload sample, press Ctrl-C to exit" )
client = IoTHubClient(CONNECTION_STRING, PROTOCOL)
client.set_options('auto_url_encode_decode', True)
f = open(PATHTOFILE, "r")
content = f.read()
client.upload_blob_async(FILENAME, content, len(content), blob_upload_conf_callback)
print ( "" )
print ( "File upload initiated..." )
But the response message is
File:C:Releaseiot-sdks-
internalsreleasepythonautomationaziotsdk_pytoolssrccc-
utilityadaptershttpapi_winhttp.c Func:HTTPAPI_CloneOption Line:1046
unknown option auto_url_encode_decode
unknown option auto_url_encode_decode and Protocol is HTTP
Not sure if this is limitation of Azure IoT Hub Python to default send Application/octet-stream
Any pointers would be appreciated
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have Azure IoT Hub Python. Trying to upload the files through this routine
def iothub_file_upload_sample_run():
try:
print ( "IoT Hub file upload sample, press Ctrl-C to exit" )
client = IoTHubClient(CONNECTION_STRING, PROTOCOL)
f = open(PATHTOFILE, "r")
content = f.read()
client.upload_blob_async(FILENAME, content, len(content), blob_upload_conf_callback)
print ( "" )
print ( "File upload initiated..." )
This works fine but the files content types are "application/octet-stream"
I went to some posts and tried by adding "client.set_options('auto_url_encode_decode', True)" as below
def iothub_file_upload_sample_run():
try:
print ( "IoT Hub file upload sample, press Ctrl-C to exit" )
client = IoTHubClient(CONNECTION_STRING, PROTOCOL)
client.set_options('auto_url_encode_decode', True)
f = open(PATHTOFILE, "r")
content = f.read()
client.upload_blob_async(FILENAME, content, len(content), blob_upload_conf_callback)
print ( "" )
print ( "File upload initiated..." )
But the response message is
File:C:Releaseiot-sdks-
internalsreleasepythonautomationaziotsdk_pytoolssrccc-
utilityadaptershttpapi_winhttp.c Func:HTTPAPI_CloneOption Line:1046
unknown option auto_url_encode_decode
unknown option auto_url_encode_decode and Protocol is HTTP
Not sure if this is limitation of Azure IoT Hub Python to default send Application/octet-stream
Any pointers would be appreciated
I have Azure IoT Hub Python. Trying to upload the files through this routine
def iothub_file_upload_sample_run():
try:
print ( "IoT Hub file upload sample, press Ctrl-C to exit" )
client = IoTHubClient(CONNECTION_STRING, PROTOCOL)
f = open(PATHTOFILE, "r")
content = f.read()
client.upload_blob_async(FILENAME, content, len(content), blob_upload_conf_callback)
print ( "" )
print ( "File upload initiated..." )
This works fine but the files content types are "application/octet-stream"
I went to some posts and tried by adding "client.set_options('auto_url_encode_decode', True)" as below
def iothub_file_upload_sample_run():
try:
print ( "IoT Hub file upload sample, press Ctrl-C to exit" )
client = IoTHubClient(CONNECTION_STRING, PROTOCOL)
client.set_options('auto_url_encode_decode', True)
f = open(PATHTOFILE, "r")
content = f.read()
client.upload_blob_async(FILENAME, content, len(content), blob_upload_conf_callback)
print ( "" )
print ( "File upload initiated..." )
But the response message is
File:C:Releaseiot-sdks-
internalsreleasepythonautomationaziotsdk_pytoolssrccc-
utilityadaptershttpapi_winhttp.c Func:HTTPAPI_CloneOption Line:1046
unknown option auto_url_encode_decode
unknown option auto_url_encode_decode and Protocol is HTTP
Not sure if this is limitation of Azure IoT Hub Python to default send Application/octet-stream
Any pointers would be appreciated
edited 4 mins ago
asked 1 hour ago
user437777
47921021
47921021
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53348922%2fazure-iot-hub-client-how-to-upload-files-in-application-json-format%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown