Skip to content

Instantly share code, notes, and snippets.

@alk-sramond
Created May 28, 2019 16:51
Show Gist options
  • Save alk-sramond/182739bfbc26f5e73b45620d840f7e3e to your computer and use it in GitHub Desktop.
Save alk-sramond/182739bfbc26f5e73b45620d840f7e3e to your computer and use it in GitHub Desktop.
upload file to public blob azure
from azure.storage.blob import (
BlockBlobService,
ContentSettings,
)
local_path = '/tmp/my/image/random.jpeg'
container_name = 'my-bucket'
content_type = 'image/jpeg'
blob_path = 'path/to/image/random.jpeg'
blob_service = BlockBlobService(
account_name='<ACCOUNT_NAME>',
account_key='<ACCOUNT_KEY>'
)
blob_service.create_blob_from_path(
container_name,
blob_path,
local_path,
content_settings=ContentSettings(content_type=content_type),
)
public_url = 'https://%s.blob.core.windows.net/%s/%s' % (
self.account_name,
self.container_name,
blob_path,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment