BadDigest DigitalOcean S3 ActiveStorage的DirectUpload失败

问题描述 投票:0回答:1

我正在尝试上传文件,但收到如下错误消息:

https://sapco.nyc3.digitaloceanspaces.com/b3vcchphzgj5m8p6ld51yk7867uu?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=QTHCA5KKQUHAKMMATAIP%2F20200503%2Fnyc3%2Fs3%2Faws4_request&X-Amz-Date=20200503T214158Z&X-Amz-Expires=10800&X-Amz-SignedHeaders=content-md5%3Bcontent-type%3Bhost&X-Amz-Signature=7b77a0f1551a262586980b709fdc44a2bc173ab6ae7279385e831493b1d13e53

<?xml version="1.0" encoding="UTF-8"?>
<Error>
   <Code>BadDigest</Code>
   <BucketName>sapco</BucketName>
   <RequestId>tx000000000000013462bc9-005eaf36fb-3518e03-nyc3a</RequestId>
   <HostId>3518e03-nyc3a-nyc</HostId>
</Error>

如何进一步调试?

到目前为止,我已经尝试过:

  1. 重置我的访问和秘密密钥。
  2. 起初,我认为这与PWA相关的工作有关,但是我迁移到了较早的分支机构,并遇到了同样的问题。
  3. 尝试了不同的文件:每个文件都有相同的错误。
  4. 同时发生在产品中。和本地。

更新1:这随机地再次开始生产。但是它仍然在本地被破坏。

对于同一个文件,我有PUT请求的2条路径,导致上述错误。

  1. https://sapco.nyc3.digitaloceanspaces.com/11eego5a6r9b4tslx7cex4p9x45u?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=QTHCA5KKQUHAKMMATAIP%2F20200504%2Fnyc3%2Fs3%2Faws4_request&X-Amz-Date=20200504T005319Z&X-Amz-Expires=10800&X-Amz-SignedHeaders=content-md5%3Bcontent-type%3Bhost&X-Amz-Signature=8d2037f7370eb137facc9d813fe35ed34e055313af06cd66819a72d886dfb018
  2. https://sapco.nyc3.digitaloceanspaces.com/z4vc7ujtvid0akqfn4uou46407zl?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=QTHCA5KKQUHAKMMATAIP%2F20200504%2Fnyc3%2Fs3%2Faws4_request&X-Amz-Date=20200504T005405Z&X-Amz-Expires=10800&X-Amz-SignedHeaders=content-md5%3Bcontent-type%3Bhost&X-Amz-Signature=b4b28cebe56a9b6c12ddfb2cc335b84080a3bfc5e34e2c66e19001230f8b7512

enter image description here

该问题必须与X-Amz-Signature的计算方式有关。

进一步研究bundle open activestorage,我可以看到它大致在这里。 https://cutt.ly/6yjc7u1

我确认Content-Length和Content-MD5都相同(相对于本地和产品)。 (分别为123803和ujNHxwCuwZ1mak927GUX3g==)。

更新2:我在Firefox中使用相同的图像进行了尝试,本地没有问题。缓存中肯定有一些令人毛骨悚然的事情。然后,我尝试了隐身窗口,这似乎也起作用。最后,我在Chrome中进行了一次硬刷新,现在我解除了封锁。不太清楚发生了什么,但给其他人留下了最后一条信息:

Chrome请求标题(不起作用,400错误)

 PUT /lw5lufemkgb7ww83pdc56qg2gb0j?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=QTHCA5KKQUHAKMMATAIP%2F20200504%2Fnyc3%2Fs3%2Faws4_request&X-Amz-Date=20200504T013900Z&X-Amz-Expires=10800&X-Amz-SignedHeaders=content-md5%3Bcontent-type%3Bhost&X-Amz-Signature=1ea88bf8550d9bab67b5bca3aa97f7b15f1a44e117dd4f5cea0744c898f70684 HTTP/1.1
 Host: sapco.nyc3.digitaloceanspaces.com
 Connection: keep-alive
 Content-Length: 0
 Pragma: no-cache
 Cache-Control: no-cache
 Accept: */*
 DNT: 1
 Content-MD5: ujNHxwCuwZ1mak927GUX3g==
 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36
 Content-Type: image/jpeg
 Origin: http://localhost:3000
 Sec-Fetch-Site: cross-site
 Sec-Fetch-Mode: cors
 Sec-Fetch-Dest: empty
 Referer: http://localhost:3000/
 Accept-Encoding: gzip, deflate, br
 Accept-Language: en

Firefox请求标题(工程)

 Host: sapco.nyc3.digitaloceanspaces.com
 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:75.0) Gecko/20100101 Firefox/75.0
 Accept: */*
 Accept-Language: en-US,en;q=0.5
 Accept-Encoding: gzip, deflate, br
 Content-Type: image/png
 Content-Length: 254924
 Referer: http://localhost:3000/
 Content-MD5: z0lzYqq/S1TYxKqL0rJMPw==
 Origin: http://localhost:3000
 DNT: 1
 Connection: keep-alive

Chrome请求标头(有效)

 Host: sapco.nyc3.digitaloceanspaces.com
 Connection: keep-alive
 Content-Length: 123803
 Pragma: no-cache
 Cache-Control: no-cache
 DNT: 1
 Content-MD5: ujNHxwCuwZ1mak927GUX3g==
 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36
 Content-Type: image/jpeg
 Accept: */*
 Origin: http://localhost:3000
 Sec-Fetch-Site: cross-site
 Sec-Fetch-Mode: cors
 Sec-Fetch-Dest: empty
 Referer: http://localhost:3000/
 Accept-Encoding: gzip, deflate, br
 Accept-Language: en
ruby-on-rails-6 rails-activestorage
1个回答
0
投票

通过强制刷新解决了该问题。

© www.soinside.com 2019 - 2024. All rights reserved.