php - 上传流式文件内容时 Azure 存储 PHP 客户端无法进行身份验证
问题描述
我正在使用azure-storage-php库将文件复制到 Azure 存储文件共享。
将文件移动到文件共享通常可以工作,但是在使用流式文件内容时,我收到身份验证错误:
Fail:
Code: 403
Value: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
details (if any): <?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:070c24e7-ABCD-EFGH-7f8e6d000000
Time:2019-10-10T11:45:35.8832342Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request 'X+WJOUaKHhOABCDEFGHIJKLMNOPQRSTUVWXYZe5Iu2k=' is not the same as any computed signature. Server used following string to sign: 'PUT
568340
text/csv
Thu, 10 Oct 2019 11:45:35 GMT
x-ms-range:bytes=0-568339
x-ms-request-id:5d9f19dfd2dae
x-ms-version:2016-05-31
x-ms-write:Update
/username/file-share-name/myFile.csv
comp:range'.</AuthenticationErrorDetail></Error>
我已经确保系统时间是同步的,因为有些人对此有疑问。
该文件甚至是在存储上创建并填充了很多行
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
我使用https://github.com/thephpleague/flysystem作为抽象层。要打开我都尝试使用的流$stream = fopen('filePath.csv', 'rb')
和$flysystem->readStream('localFilesystem', 'filePath.csv');
解决方案
在 Gaurav Mantri 的提示之后,我发现只有当流文件的大小低于某个阈值时才会发生错误。就我而言,这大约是 4MB。
上传小于 4MB 的流式文件会导致上述错误。
上传大于 4MB 的流式文件就可以了。
不幸的是,我没有解释为什么会发生这种情况。我现在使用一种解决方法在上传之前检查文件大小,然后使用直接上传或使用流来获取更大的文件。
推荐阅读
- android - 自动下载适用于 Android 的 google-services.json
- symfony - Symfony - 如果选中该复选框,则禁用必填字段
- mysql - 编辑或创建模型时从另一个表连接表设置默认值
- animation - 检测线与多边形的交点数
- maple - e 不等于 Maple 2019.1 中的 exp
- css - 关键帧恢复自身 (CSS)
- java - Android Studio 3.5.3 不导入某些小部件
- asp.net-core - ASP.NET Core:如何在不访问 Internet 的情况下验证 JWT
- html - 在屏幕右侧显示 bootstrap 4.4 导航栏内容
- javascript - 一键二值(反应)