adopted-ember-addons / adopted-ember-addons/ember-file-upload

S3 Upload

未關閉
#52 8 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
documentation good first issue
主要語言
TypeScript
星號
196
分支
115
PR 合併指標
30 天內沒有已合併 PR

描述

I've done everything like in your tutorial except your Ruby script. I've used node js aws-sdk:

```
const aws = require('aws-sdk');
var config = require('../../server/config.json');
aws.config = config.aws;

const s3 = new aws.S3();
const s3Params = {
Bucket: config.aws.bucket,
Key: instance.filename,
Expires: 60,
ACL: 'public-read'
};

s3.getSignedUrl('putObject', s3Params, (err, signedUrl) => {
if(err){
return next(err);
}
instance.uploadUrl = signedUrl;
next();
});
```

So I've got signed URL

`Request URL:https://f.workdoer.com.s3.amazonaws.com/IMG_4875.PNG.png?AWSAccessKeyId=AKIAIFVWPIVVIGIONPXA&Expires=1502381111&Signature=Af9meXlMA7qj5HYALs7LzhWaftc%3D&x-amz-acl=public-read`

```
Request headers:
PUT /IMG_4875.PNG.png?AWSAccessKeyId=AKIAIFVWPIVVIGIONPXA&Expires=1502381111&Signature=Af9meXlMA7qj5HYALs7LzhWaftc%3D&x-amz-acl=public-read HTTP/1.1
Host: f.workdoer.com.s3.amazonaws.com
Connection: keep-alive
Content-Length: 130838
Accept: application/json,text/javascript
Origin: http://localhost:4200
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarygDui83iohothuh7E
Referer: http://localhost:4200/app/team/1/project/15/list/task/2074
Accept-Encoding: gzip, deflate, br
Accept-Language: ru,en-US;q=0.8,en;q=0.6,uk;q=0.4,it;q=0.2,de;q=0.2
```

```
Request Payload:
------WebKitFormBoundarygDui83iohothuh7E
Content-Disposition: form-data; name="Content-Type"

image/png
------WebKitFormBoundarygDui83iohothuh7E
Content-Disposition: form-data; name="file"; filename="IMG_4875.PNG.png"
Content-Type: image/png

------WebKitFormBoundarygDui83iohothuh7E--
```

And I've got from Amazon:

```
SignatureDoesNotMatchThe request signature we calculated does not match the signature you provided. Check your key and signing method.AKIAIFVWPIVVIGIONPXAPUT

multipart/form-data; boundary=----WebKitFormBoundarygDui83iohothuh7E
1502381111
x-amz-acl:public-read
/f.workdoer.com/IMG_4875.PNG.pngAf9meXlMA7qj5HYALs7LzhWaftc=
```

Something wrong with your request, because when I put it with CURL:

`curl -k -X PUT -T "IMG_4875.PNG.png" "https://f.workdoer.com.s3.amazonaws.com/IMG_4875.PNG.png?AWSAccessKeyId=AKIAIFVWPIVVIGIONPXA&Expires=1502381111&Signature=Af9meXlMA7qj5HYALs7LzhWaftc%3D&x-amz-acl=public-read"`

It's successfully uploaded. What I'm doing wrong?

Here is my bucket policy:

```
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "Allow Public Access to All Objects",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"s3:DeleteObject",
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::f.workdoer.com/*"
}
]
}

```
And cors:
```




*
PUT
POST
3000
Location
Content-Type
x-amz-acl
origin
accept


```

Thanks for any help.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。