当我使用local
作为存储服务时,将创建一个blob,如下所示:
ActiveStorage::Blob Create (0.3ms) INSERT INTO "active_storage_blobs" ("key", "filename", "content_type", "metadata", "byte_size", "checksum", "created_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id" [["key", "9GRt2oNEvae3MV6gNxzLBfzY"], ["filename", "22.jpg"], ["content_type", "image/jpeg"], ["metadata", "{\"identified\":true}"], ["byte_size", 38908], ["checksum", "HWkFPEByP/zWdy1nDW6FHg=="], ["created_at", "2018-07-09 07:53:34.790031"]]
注意其中的checksum
是HWkFPEByP/zWdy1nDW6FHg==
,当我将存储服务从本地切换到亚马逊时,文件上传到s3失败,错误提示:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>BadDigest</Code><Message>The Content-MD5 you specified did not match what we received.</Message><ExpectedDigest>1d0c39a9937ce0bec2952fe2be1c4f51</ExpectedDigest><CalculatedDigest>iSb43Wodm0WQp/hAZpKKOg==</CalculatedDigest><RequestId>9018707DCFFCA829</RequestId><HostId>Nop+tXGRYKJlhIy7LU+d4nYtba9i1n3BYnNM+Il60WlH0ZhR53SyHCS2Nox+KVgie9XTIlTOGTg=</HostId></Error>
请注意,计算所得的摘要为iSb43Wodm0WQp/hAZpKKOg==
,我不确定是哪个错误,是Rails还是Amazon,请在这里找到我要上传的图片