Created
May 28, 2019 16:51
-
-
Save alk-sramond/182739bfbc26f5e73b45620d840f7e3e to your computer and use it in GitHub Desktop.
upload file to public blob azure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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