codestates / codestates/BaedalDutch

[Error-log] S3 이미지 업로드 AWS 에러 (feat. ACL)

Open
#83 0 comments 0 reactions 1 assignee Claimed by @leo-labbb View on GitHub
error-log
Dominant language
JavaScript
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Description

### ISSUE
- Group: `client`
- Type: `error`
- Detail:

### Error Message
> 스크린샷 또는 코드 공유
![스크린샷 2022-05-09 17 28 31](https://user-images.githubusercontent.com/92617810/167410904-4917e02d-9e96-4a09-bbac-8a86e7c06df5.png)
- 클라이언트에서 S3로 보내주는 로직을 구현하고 react-app에서 실행했지만 계속 오류가 뜨고 디버거가 실행되었다.
```js
const params = {
ACL: 'public-read',
Body: file,
Bucket: S3_BUCKET,
Key: file.name,
ContentType: 'image/png, image/jpeg, image/gif',
};

myBucket.putObject(params, (err, data) => {
console.log('params:', params);
const imageSrc = `https://${S3_BUCKET}.s3.${REGION}.amazonaws.com/${file.name}`;
console.log('imageSrc:', imageSrc);
```
### Solution
> 원인과 해결과정
이 과정에서 콘솔 로그들은 모두 잘 찍혀들어와서 로직 상 문제라기보다 S3 설정이 문제라고 생각했고
```js
console.log('loginUser:', loginUser);
console.log('data:', data);
console.log('err:', err);
```
`putObject`의 두번째 인자인 `data`와 `err`까지 모두 데이터로 찍었더니 맨 위 사진같이 에러 로그가 출력되었다.
```js
The bucket does not allow ACLs
```
이 문장으로 구글링을 해보니 S3에서 권한 - 객체 소유권 편집 문제였고 아래와 같이 수정하니 잘 작동했다 !
![스크린샷 2022-05-09 17 28 50](https://user-images.githubusercontent.com/92617810/167411740-bdc8b84d-1399-4f5b-a8f9-07e7c4f6701c.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.