codestates / codestates/Senna-server

[Error] multer-s3로 삭제 요청시 S3 버킷 내 요청한 객체가 삭제 되지 않음

Open
#46 0 comments 0 reactions 0 assignees View on GitHub
Error
Dominant language
JavaScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

### 어떤 에러인가요?
삭제 요청하면 응답은 true로 오나 실제 버킷에서는 요청한 객체가 삭제되지 않았다.

### $ 터미널의 에러 코드를 여기 넣어주세요.

```
const path = images.map(img => img.location)
path.forEach(path => {
//console.log('path', path[1])
s3.deleteObject({
Bucket: 'senna-image',
Key: path[1]
}, (err, data) => {
if(err) {
console.log(err)
}
console.log('삭제 data', data)
})
})
```

### 에러 핸들링 방법
- key에 filename 값만 들어가야하는데 url이 들어간 값을 넣었더니 에러는 안나도 삭제가 되지 않았다.
- filename만 뽑아서 넣을 수 있도록 하였다.
```
let deleteImg = beforeImg.filter(img => !update.image.includes(img)).map(el => el.split('com/'))
deleteImg.forEach(path => {
s3.deleteObject({
Bucket: 'senna-image'
Key: path[1]
}, (err, data) => {
if(err) {
console.log(err)
}
console.log('삭제 data', data)
})
})
```

### 에러 핸들링을 위해 참고한 레퍼런스 링크

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the code that builds image locations and calls s3.deleteObject, using the snippets in the issue as the entry point. Check how the S3 object key is derived from each URL and verify deletion against the senna-image bucket; done means the requested objects are actually removed rather than only returning a true response.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript
Domain
backend, cloud
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.