Create Version from Blob Upload
This example shows how to create a new version for a product by uploading files to a designated workflow blob drop-in:
import os
from azure.storage.blob import BlobServiceClient
from io import BufferedReader
from io import BytesIO
import json
CONTAINER_NAME = '!!!YOUR CONTAINER NAME HERE!!!'
connection_string = "!!!YOUR CONNECTION STRING HERE!!!"
def uploadFileToBlob(filename, buffer):
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
blob_client = blob_service_client.get_blob_client(container=CONTAINER_NAME, blob=filename)
blob_client.upload_blob(buffer, overwrite=True)
files = [
{
"name": "file01.obj",
"path": "W:\\mydata\\"
},
{
"name": "file02.ftr",
"path": "W:\\mydata\\"
}
]
filesUpload = []
for f in files:
with open(f["path"]+f["name"], "rb") as data:
uploadFileToBlob(f["name"], data)
filesUpload.append(f["name"])
manifest = {
"user": "me@gmail.com",
"product": "MY_WORKFLOW_PRODUCT_ID",
"comment": "A test version",
"files": filesUpload
}
bytes=bytes(json.dumps(manifest), 'utf-8')
buffer = BytesIO(bytes)
uploadFileToBlob("manifest.json", buffer)