【问题标题】:Azure Storage PHP client fails to authenticate when uploading streamed file content上传流文件内容时 Azure 存储 PHP 客户端无法进行身份验证
【发布时间】: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-&gt;readStream('localFilesystem', 'filePath.csv');

【问题讨论】:

  • 您要检查的一件事是您上传的流的大小。
  • @GauravMantri 查看文件大小是一个很好的提示。事实证明,流文件(在我的情况下)需要大约 4MB 或更大才能不会出现此错误。你对此有什么解释吗?
  • 我不知道:)。我刚刚看到错误详细信息并推断流大小可能是一个问题。

标签: php azure azure-storage-files


【解决方案1】:

在 Gaurav Mantri 的提示后,我发现只有当流文件的大小低于某个阈值时才会发生错误。就我而言,这大约是 4MB。

上传

上传大于 4MB 的流式文件就可以了。

很遗憾,我无法解释为什么会发生这种情况。 我现在使用一种解决方法在上传之前检查文件大小,然后使用直接上传或使用流来获取更大的文件。

【讨论】:

    猜你喜欢
    • 2021-12-17
    • 2022-01-18
    • 1970-01-01
    • 2020-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多