【发布时间】:2023-03-31 22:25:01
【问题描述】:
我正在尝试使用 SAS 令牌将文件/数据上传到 Azure 存储。 我可以使用以下方法在没有 SAS 令牌的情况下成功实现这一目标:
sendToBlob (Uint8List bytes)async { var storage = AzureStorage.parse('DefaultEndpointsProtocol=https;AccountName=#;AccountKey=#==;EndpointSuffix=core.windows.net'); await storage.putBlob('/test/2.txt',bodyBytes: bytes); }
当我生成一个 SAS 令牌并使用以下格式编写的连接字符串时,我收到一个解析错误:
"BlobEndpoint=https://#.blob.core.windows.net/;QueueEndpoint=https://#.queue.core.windows.net/;FileEndpoint=https://#.file.core.windows.net/;TableEndpoint=https://#.table.core.windows.net/;SharedAccessSignature=sv=#"
尝试发送不带连接字符串的put请求,我的方法如下:
uploadtoAzure(String sas)async{ try { var url = 'https://#.blob.core.windows.net/test/4.txt?'+sas; Map<String, String> headers = ({"x-ms-blob-type": "BlockBlob"}); final response = await http.put( url, headers: headers, body: 'hi' ); print(response.statusCode); } on DioError catch (e) { if(e.response.statusCode == 404){ print(e.message); }else{ print(e.message); } } }
知道我是我要上传到的存储帐户的所有者和存储 Blob 数据贡献者,并且 SAS 令牌未过期,这会导致 403 AuthorizationPermissionMismatch 错误。 p>
¿<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthorizationPermissionMismatch</Code><Message>This request is not authorized to perform this operation using this permission.
RequestId:bc7f5bb4-c01e-0066-0459-9a6d45000000
Time:2020-10-04T14:16:54.7302685Z</Message></Error>
有没有一种方法可以使用带有 SAS 令牌的连接字符串将数据从颤振上传到天蓝色?我该如何解决这个问题?
感谢任何帮助。
【问题讨论】:
标签: azure flutter dart connection-string