gpt4 book ai didi

python - 覆盖 Blob 存储上的 Blob - 出现 "read only"异常

转载 作者:行者123 更新时间:2023-12-03 01:22:16 25 4
gpt4 key购买 nike

我想要覆盖 Azure Blob 存储上的 blob myfile.txt。我使用此代码,其中 blob_url 包含 SAS token 。该 blob 的访问级别为“私有(private)”。

但是,我总是收到此错误:

Result: Failure Exception: OSError: [Errno 30] Read-only file system: './TimerTrigger1/myfile.txt' Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 402, in _handle__invocation_request call_result = await self._loop.run_in_executor( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 606, in _run_sync_func return ExtensionManager.get_sync_invocation_wrapper(context, File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/extension.py", line 215, in _raw_invocation_wrapper result = function(**args) File "/home/site/wwwroot/TimerTrigger1/__init__.py", line 32, in main open(filename, 'wb').write(r.content)

这是我的 Python 代码:

blob_url = "https://me.blob.core.windows.net/mycontainer/myfile.txt?sp=r&st=2021-10-05T14:07:24Z&se=2021-10-05T22:07:24Z&spr=https&sv=2020-08-04&sr=b&sig=asdfasdfasdfa"
blob_client = BlobClient.from_blob_url(
blob_url=blob_url
)
with open("myfile.txt", "rb") as blob_file:
blob_client.upload_blob(data=blob_file)

关于如何实现这一目标有什么想法吗?

最佳答案

这是因为您在 SAS token (sp=r) 中只有读取权限。为了更新 blob,您还需要 token 中的写入权限。

请创建一个具有读取写入权限的 SAS token ,您应该能够更新该 blob。您的 SAS URL 应类似于:

https://me.blob.core.windows.net/mycontainer/myfile.txt?sp=rw&st=2021-10-05T14:07:24Z&se=2021-10-05T22:07:24Z&spr=https&sv=2020-08-04&sr=b&sig=asdfasdfasdfa

关于python - 覆盖 Blob 存储上的 Blob - 出现 "read only"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69453267/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com