Cloudreve 使用Scaleway的对象存储时上传出错

brc7rcf0  于 2021-12-01  发布在  Java
关注(0)|答案(4)|浏览(308)

Describe the bug

存储策略添加了Scaleway Object Storage,它是支持S3协议的,于是我添加时选的Amazon S3。使用时,能够新建文件,能够编辑,但是选择上传文件时,会报403 Forbidden。
看着像是post表单里面name那里的问题,Scaleway不支持这个。

To Reproduce

Steps to reproduce the behavior:

  1. 使用Amazon S3选项添加Scaleway Object Storage,并切换到这个存储策略
  2. 上传文件

Expected behavior

成功上传

Screenshots

Desktop (please complete the following information):

  • OS: Windows 10 LTSC
  • Browser Firefox, Edge
  • Version 88b4, 89.0.774.63

Additional context

POST的数据

-----------------------------172405511219134686112034991713
Content-Disposition: form-data; name="name"

avatar.png
-----------------------------172405511219134686112034991713
Content-Disposition: form-data; name="policy"

eyJleHBpcmF0aW9uIjoiMjAyMS0wMy0zMFQxNDowNTo0MVoiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJ3ZWJkaXNrIn0sWyJzdGFydHMtd2l0aCIsIiRrZXkiLCJ1cGxvYWRzLzIwMjEvMDMvMzAvM0loN3lnM05fYXZhdGFyLnBuZyJdLFsic3RhcnRzLXdpdGgiLCIkc3VjY2Vzc19hY3Rpb25fcmVkaXJlY3QiLCJodHRwczovL3dlYmRpc2sub3hvLmljdToyNTIxMy9hcGkvdjMvY2FsbGJhY2svczMvaGpTdlVGN1d3VFJoQkZXRWtvSW1KeDJ0QzVUc0FnOWwiXSxbInN0YXJ0cy13aXRoIiwiJG5hbWUiLCIiXSxbInN0YXJ0cy13aXRoIiwiJENvbnRlbnQtVHlwZSIsIiJdLHsieC1hbXotYWxnb3JpdGhtIjoiQVdTNC1ITUFDLVNIQTI1NiJ9LHsieC1hbXotY3JlZGVudGlhbCI6IlNDV1NGS0hLSzhUOFNIUjJXOFhQLzIwMjEwMzMwL25sLWFtcy9zMy9hd3M0X3JlcXVlc3QifSx7IngtYW16LWRhdGUiOiIyMDIxMDMzMFQxMzM1NDFaIn1dfQ==
-----------------------------172405511219134686112034991713
Content-Disposition: form-data; name="key"

uploads/2021/03/30/3Ih7yg3N_avatar.png
-----------------------------172405511219134686112034991713
Content-Disposition: form-data; name="success_action_redirect"

https://example.com/api/v3/callback/s3/hjSvUF7WwTRhBFWEkoImJx2tC5TsAg9l
-----------------------------172405511219134686112034991713
Content-Disposition: form-data; name="x-amz-algorithm"

AWS4-HMAC-SHA256
-----------------------------172405511219134686112034991713
Content-Disposition: form-data; name="x-amz-credential"

SCWSFKHKK8T8SHR2W8XP/20210330/nl-ams/s3/aws4_request
-----------------------------172405511219134686112034991713
Content-Disposition: form-data; name="x-amz-signature"

9a70c415b99fd51fe1504dfee58fb1f2a330c47737a5fecc18af3cf9e899b65e
-----------------------------172405511219134686112034991713
Content-Disposition: form-data; name="x-amz-date"

20210330T133541Z
-----------------------------172405511219134686112034991713
Content-Disposition: form-data; name="Content-Type"

image/png
-----------------------------172405511219134686112034991713
Content-Disposition: form-data; name="file"; filename="avatar.png"
Content-Type: image/png

报错信息

[Cloudreve-uploader][error] err:  
Object { code: -200, message: "HTTP 错误。", file: {…}, response: "<?xml version='1.0' encoding='UTF-8'?>\n<Error><Code>AccessDenied</Code><Message>Field $name does not met required policy conditions</Message><RequestId>tx980379244e924d4099f6a-006063292f</RequestId></Error>", status: 403, responseHeaders: "content-type: application/xml\r\n" }
​
code: -200
​
file: Object { id: "o_1f21lhmbd9ls198o12va13ma1o82d", name: "avatar.png", type: "image/png", … }
​
message: "HTTP 错误。"
​
response: "<?xml version='1.0' encoding='UTF-8'?>\n<Error><Code>AccessDenied</Code><Message>Field $name does not met required policy conditions</Message><RequestId>tx980379244e924d4099f6a-006063292f</RequestId></Error>"
​
responseHeaders: "content-type: application/xml\r\n"
​
status: 403
​
<prototype>: Object { … }
uploader_s3.js:112:29

Scaleway 关于POST的说明:POST Object
Amazon S3里的POST Object

这两个里面Form Fields都没有name这项的样子

aurhwmvo

aurhwmvo1#

测试删除name的policy condition之后成功上传,删除的是这行

q3aa0525

q3aa05252#

😂 删除这一行 Amazon S3 挂了

dgiusagp

dgiusagp3#

好奇怪,S3的policy文档里的conditions没有name这一项,Scaleway的人说不需要这个,我就提交了PR,再深入的我也不清楚了😂

bjg7j2ky

bjg7j2ky4#

可能后端删了前端也要相应处理,等一个前端大佬,这块代码看着有点迷糊

相关问题