I'm trying to upload a PDF to an Azure blob store, and then download and read it. The upload works fine, and when I open it in the Azure Storage Explorer, the file opens fine. However, when I try to download it, I get an Octet stream and I cant figure out how to convert it back into a PDF. Im doing this all through a Function App so I'm not sure if writing everything to a temporary file will help. I tried it and I got a corrupted pdf as my output. My code is as follows.
Upload:
blob_service_client = BlobServiceClient.from_connection_string(connect_str)
container_name = 'testblobstore123'
file = req.files['file']
try:
blob_client = blob_service_client.get_blob_client(container=container_name, blob=file.filename)
blob_client.upload_blob(file)
except Exception as e:
print(e)
return "Unspecified Error"
Download:
blob_service_client = BlobServiceClient.from_connection_string(connect_str)
container_name = 'testblobstore123'
file = req.form['file']
blob_client = blob_service_client.get_blob_client(container=container_name, blob=file)
# data = blob_service_client.get_data_to_text(container_name, file)
data = blob_client.download_blob().readall()
