本文整理汇总了Python中azure.storage.blob.BlobService.put_block_blob_from_bytes方法的典型用法代码示例。如果您正苦于以下问题:Python BlobService.put_block_blob_from_bytes方法的具体用法?Python BlobService.put_block_blob_from_bytes怎么用?Python BlobService.put_block_blob_from_bytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.storage.blob.BlobService
的用法示例。
在下文中一共展示了BlobService.put_block_blob_from_bytes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generateImageUrl
# 需要导入模块: from azure.storage.blob import BlobService [as 别名]
# 或者: from azure.storage.blob.BlobService import put_block_blob_from_bytes [as 别名]
def generateImageUrl(request):
account_name = "faceemoji"
account_key = "kaoJiy0T7r6sXyo4wFYKCLgpAXbILKvkloeF+kFpCEUxC+bL9BxGA3WtofVxHcLPn3lMjw/UO/0sS1GCN3/AQw=="
blob_service = BlobService(account_name, account_key)
content = base64.b64decode(request.data)
st = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d-%H-%M-%S')
blob_name = hashlib.sha224(st).hexdigest() + 'image.png'
blob_service.put_block_blob_from_bytes('image', blob_name, content)
img_url = blob_service.make_blob_url('image', blob_name)
return img_url
示例2: pushToAzureCDN
# 需要导入模块: from azure.storage.blob import BlobService [as 别名]
# 或者: from azure.storage.blob.BlobService import put_block_blob_from_bytes [as 别名]
def pushToAzureCDN (data):
import pickle
from azure.storage.blob import BlobService
blob_service = BlobService(account_name=azureAccount, account_key=azureAccountKey)
blob_service.put_block_blob_from_bytes(
azureContainer,
azureFile,
pickle.dumps(data),
content_encoding='application/octet-stream'
)
示例3: save_image_to_azure
# 需要导入模块: from azure.storage.blob import BlobService [as 别名]
# 或者: from azure.storage.blob.BlobService import put_block_blob_from_bytes [as 别名]
def save_image_to_azure(profile, url):
try:
response = request('GET', url)
response.raise_for_status()
except ConnectionError:
pass
else:
service = BlobService(
account_name=storagesettings.AZURE_ACCOUNT_NAME,
account_key=storagesettings.AZURE_ACCOUNT_KEY)
service.put_block_blob_from_bytes(
'avatars',
profile.id,
response.content,
x_ms_blob_content_type=response.headers['content-type']
)