[英]Uploading files to Azure using SAS
I have a couple of questions regarding uploading to SAS using Python.我有几个关于使用 Python 上传到 SAS 的问题。 I have a SAS provided by our client, in the form of:
我有一个由我们的客户提供的 SAS,形式为:
https://<company_name>.blob.core.windows.net/<container_name>?sp<long_string>
I tried following this code: Uploading csv files to azure container using SAS URI in python?我尝试遵循此代码: Uploading csv files to azure container using SAS URI in Z23EEEB4347BDD26BDDFC6B7EE
from azure.storage.blob import BlobClient
upload_file_path="d:\\a11.csv"
sas_url="https://xxx.blob.core.windows.net/test5/a11.csv?sastoken"
client = BlobClient.from_blob_url(sas_url)
with open(upload_file_path,'rb') as data:
client.upload_blob(data)
print("**file uploaded**")
and I get the following error:我收到以下错误:
azure.core.exceptions.ResourceExistsError: Public access is not permitted on this storage account.
RequestId:946bd6ea-e01e-0040-3932-ee6a4e000000
Time:2021-12-11T01:58:51.0010075Z
ErrorCode:PublicAccessNotPermitted
The Azure SDK mentions using an account name which I do not have so that's a no go (I can upload file using the Azure Storage Explorer however that is slow for what I need, but I know the SAS is working). The Azure SDK mentions using an account name which I do not have so that's a no go (I can upload file using the Azure Storage Explorer however that is slow for what I need, but I know the SAS is working). Am I using the wrong code for uploading?
我是否使用了错误的代码进行上传? Also, it is not clear how to tell the code where to upload the file to in the blob container?
另外,不清楚如何告诉代码将文件上传到 blob 容器中的哪个位置? Eg if I wanted to upload a file
image.jpg
to 2021-12-11/dataset_1/
, where would I put that in the code?例如,如果我想将文件
image.jpg
上传到2021-12-11/dataset_1/
,我会将它放在代码的哪个位置?
I tried to upload file using SAS URL which i have generated from container, and unable to upload the file.我尝试使用从容器生成的 SAS URL 上传文件,但无法上传文件。 Instead of using SAS URL of Container use your storage account SAS URL which is worked fine for me with the same code which you have given.
Instead of using SAS URL of Container use your storage account SAS URL which is worked fine for me with the same code which you have given.
cmd
Here are the output screenshots:cmd
这是 Z78E6221F6393D135CEDZF 截图1 For more information please refer this MS DOC有关更多信息,请参阅此MS DOC
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.