本文整理汇总了Python中azure.storage.blob.BlobService.make_blob_url方法的典型用法代码示例。如果您正苦于以下问题:Python BlobService.make_blob_url方法的具体用法?Python BlobService.make_blob_url怎么用?Python BlobService.make_blob_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.storage.blob.BlobService
的用法示例。
在下文中一共展示了BlobService.make_blob_url方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generateImageUrl
# 需要导入模块: from azure.storage.blob import BlobService [as 别名]
# 或者: from azure.storage.blob.BlobService import make_blob_url [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: copyBlobToBlob
# 需要导入模块: from azure.storage.blob import BlobService [as 别名]
# 或者: from azure.storage.blob.BlobService import make_blob_url [as 别名]
def copyBlobToBlob(sourceUrl, sourceKey, destUrl, destKey):
blobservice = BlobService(destUrl, destkey)
srcblobservice = BlobService(SourceUrl, srckey)
today = datetime.datetime.utcnow()
todayPlusMonth = today + datetime.timedelta(1)
todayPlusMonthISO = todayPlusMonth.replace(microsecond=0).isoformat() + 'Z'
srcSasParam = srcblobservice.generate_shared_access_signature(container,
filename, SharedAccessPolicy(AccessPolicy(None, todayPlusMonthISO, "r"), None))
srcUrl = srcblobservice.make_blob_url(container, filename,
sas_token=srcSasParam)
print srcUrl
blobservice.copy_blob(container, filename, srcUrl)
示例3: copyBlobToBlob
# 需要导入模块: from azure.storage.blob import BlobService [as 别名]
# 或者: from azure.storage.blob.BlobService import make_blob_url [as 别名]
def copyBlobToBlob(sourceUrl, sourceKey, destUrl, destKey):
sourceParts = split_storage_url(sourceUrl)
destParts = split_storage_url(destUrl)
blobservice = BlobService(destParts[0], destKey)
srcblobservice = BlobService(sourceParts[0], sourceKey)
today = datetime.datetime.utcnow()
todayPlusMonth = today + datetime.timedelta(1)
todayPlusMonthISO = todayPlusMonth.replace(microsecond=0).isoformat() + 'Z'
srcSasParam = srcblobservice.generate_shared_access_signature(sourceParts[2],
sourceParts[3], SharedAccessPolicy(AccessPolicy(None, todayPlusMonthISO, "r"), None))
srcUrl = srcblobservice.make_blob_url(sourceParts[2], sourceParts[3],
sas_token=srcSasParam)
print destParts
blobservice.copy_blob(destParts[2], destParts[3], srcUrl)
示例4: get_container_details
# 需要导入模块: from azure.storage.blob import BlobService [as 别名]
# 或者: from azure.storage.blob.BlobService import make_blob_url [as 别名]
def get_container_details(creds, resource_group_name, account_name, container_name):
keys = _get_storage_account_keys(creds, resource_group_name, account_name)
blob_service = BlobService(account_name, keys.key1)
model = StorageAccountContainerDetails()
model.container_name = container_name
model.sas_policy = _get_shared_access_policy(BlobSharedAccessPermissions.READ)
model.blobs = []
for blob in blob_service.iterate_blobs(container_name, include="metadata"):
sas_token = blob_service.generate_shared_access_signature(container_name, blob.name, model.sas_policy)
blob.sas_url = blob_service.make_blob_url(container_name, blob.name, sas_token=sas_token)
raw_md5 = b64decode(blob.properties.content_md5)
hex_md5 = "".join([hex(val)[2:] for val in raw_md5])
blob.properties.content_hex_md5 = hex_md5
model.blobs.append(blob)
return model
示例5: module_impl
# 需要导入模块: from azure.storage.blob import BlobService [as 别名]
# 或者: from azure.storage.blob.BlobService import make_blob_url [as 别名]
#.........这里部分代码省略.........
file_path,
x_ms_meta_name_values,
x_ms_blob_cache_control,
x_ms_blob_content_encoding,
x_ms_blob_content_language,
x_ms_blob_content_type
)
results['blob'] = get_blob_facts(bs, container_name, blob_name)
results['changed'] = True
results['msg'] = 'Successfully updloaded file.'
return results
if mode == 'list':
container = container_check(bs, container_name)
response = bs.list_blobs(
container_name,
prefix,
marker,
max_results
)
results['blobs'] = []
for blob in response.blobs:
b = dict(
name = blob.name,
snapshot = blob.snapshot,
last_modified = blob.properties.last_modified,
content_length = blob.properties.content_length,
blob_type = blob.properties.blob_type,
)
results['blobs'].append(b)
return results
if mode == 'get':
if file_path is None:
raise Exception("Parameter error: file_path cannot be None.")
container = container_check(bs, container_name)
blob = blob_check(bs, container_name, blob_name)
path_exists = path_check(file_path)
if not path_exists or overwrite == 'always':
if not check_mode:
bs.get_blob_to_path(container_name, blob_name, file_path)
results['changed'] = True
results['msg'] = "Blob %s successfully downloaded to %s." % (blob_name, file_path)
return results
if path_exists:
md5_remote = blob['content-md5']
md5_local = get_md5(file_path)
if md5_local == md5_remote:
sum_matches = True
if overwrite == 'always':
if not check_mode:
bs.get_blob_to_path(container_name, blob_name, file_path)
results['changed'] = True
results['msg'] = "Blob %s successfully downloaded to %s." % (blob_name, file_path)
else:
results['msg'] = "Local and remote object are identical, ignoring. Use overwrite parameter to force."
else:
sum_matches = False
if overwrite in ('always', 'different'):
if not check_mode:
bs.get_blob_to_path(container_name, blob_name, file_path)
results['changed'] = True
results['msg'] = "Blob %s successfully downloaded to %s." % (blob_name, file_path)
else:
results['msg'] ="WARNING: Checksums do not match. Use overwrite parameter to force download."
if sum_matches is True and overwrite == 'never':
results['msg'] = "Local and remote object are identical, ignoring. Use overwrite parameter to force."
return results
if mode == 'get_url':
if not blob_name:
raise Exception("Parameter error: blob_name cannot be None.")
container = container_check(bs, container_name)
blob = blob_check(bs, container_name, blob_name)
url = bs.make_blob_url(
container_name=container_name,
blob_name=blob_name,
sas_token=access_token)
results['url'] = url
results['msg'] = "Url: %s" % url
return results
if mode == 'get_token':
if hours == 0 and days == 0:
raise Exception("Parameter error: expecting hours > 0 or days > 0")
container = container_check(bs, container_name)
blob = blob_check(bs, container_name, blob_name)
results['blob_name'] = blob_name
sap = get_shared_access_policy(permissions, hours=hours, days=days)
token = bs.generate_shared_access_signature(container_name, blob_name, sap)
results['access_token'] = token
return results