【发布时间】:2020-02-07 22:00:35
【问题描述】:
我正在使用 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');
【问题讨论】:
-
您要检查的一件事是您上传的流的大小。
-
@GauravMantri 查看文件大小是一个很好的提示。事实证明,流文件(在我的情况下)需要大约 4MB 或更大才能不会出现此错误。你对此有什么解释吗?
-
我不知道:)。我刚刚看到错误详细信息并推断流大小可能是一个问题。
标签: php azure azure-storage-files