21 lines
789 B
Python
21 lines
789 B
Python
from azure.identity import DefaultAzureCredential
|
|
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
|
|
|
|
|
|
def save(path, filename):
|
|
account_url = "https://theecho.blob.core.windows.net"
|
|
default_credential = DefaultAzureCredential()
|
|
|
|
# Create the BlobServiceClient object
|
|
blob_service_client = BlobServiceClient(account_url, credential=default_credential)
|
|
|
|
container_name = "ppics"
|
|
|
|
# Create a blob client using the local file name as the name for the blob
|
|
blob_client = blob_service_client.get_blob_client(container=container_name, blob=filename)
|
|
|
|
# Upload the created file
|
|
with open(file=path, mode="rb") as data:
|
|
blob_client.upload_blob(data)
|
|
url = account_url + "/" + container_name + "/" + filename
|
|
return url |