将文件从 URL 上传到 Microsoft Azure Blob 存储 [英] Upload file from URL to Microsoft Azure Blob Storage

查看:45
本文介绍了将文件从 URL 上传到 Microsoft Azure Blob 存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从本地路径(从我的电脑)上传文件没有问题.但是,我没有找到如何从特定 URL 上传.

It is not a problem to upload file from local path (from my computer). However, I didn't find how to upload from specific URL.

如果可能的话 - 需要 Python 解决方案.只有本地文件的文档 https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-python

If it possible - solution in Python is needed. There is documentation only for local files https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-python

如何对远程 URL 执行此操作?

How to do this for remote URL?

推荐答案

您可以利用 async copy blob 功能从可公开访问的 URL 创建 blob.请参阅下面的示例代码:

You can make use of async copy blob functionality to create a blob from a publicly accessible URL. Please see sample code below:

from azure.storage.blob import BlockBlobService, PublicAccess
from azure.storage.blob.models import Blob

def run_sample():
    block_blob_service = BlockBlobService(account_name='your_name', account_key='your_key')
    container_name ='t1s'

    block_blob_service.copy_blob(container_name,'remoteURL.pdf','https://media.readthedocs.org/pdf/azure-storage/v0.20.3/azure-storage.pdf')


# Main method.
if __name__ == '__main__':
    run_sample()

这篇关于将文件从 URL 上传到 Microsoft Azure Blob 存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆