将文件从 URL 上传到 Microsoft Azure Blob 存储 [英] Upload file from URL to Microsoft Azure Blob Storage
问题描述
从本地路径(从我的电脑)上传文件没有问题.但是,我没有找到如何从特定 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屋!