견적서 복사 로직 수정
[작업내용] : 이미지 존재 여부 확인 후 복사 진행
This commit is contained in:
parent
5412aff4ef
commit
387a1fd577
@ -12,28 +12,29 @@ const s3 = new S3Client({
|
||||
})
|
||||
|
||||
export async function POST(req) {
|
||||
try {
|
||||
const { objectNo, planNo, newObjectNo, newPlanNo } = await req.json()
|
||||
const { objectNo, planNo, newObjectNo, newPlanNo } = await req.json()
|
||||
|
||||
const responseArray = []
|
||||
const responseArray = []
|
||||
|
||||
// const isExistImage1 = await s3.send(
|
||||
// new GetObjectCommand({
|
||||
// Bucket,
|
||||
// Key: `Drawing/${objectNo}_${planNo}_1.png`,
|
||||
// }),
|
||||
// )
|
||||
//견적서1 번 이미지
|
||||
const isExistImage1 = await s3.send(
|
||||
new GetObjectCommand({
|
||||
Bucket,
|
||||
Key: `Drawing/${objectNo}_${planNo}_1.png`,
|
||||
}),
|
||||
)
|
||||
|
||||
// const isExistImage2 = await s3.send(
|
||||
// new GetObjectCommand({
|
||||
// Bucket,
|
||||
// Key: `Drawing/${objectNo}_${planNo}_1.png`,
|
||||
// }),
|
||||
// )
|
||||
|
||||
// console.log('🚀 ~ isExistImage1:', isExistImage1.$metadata.httpStatusCode === 200)
|
||||
// console.log('🚀 ~ isExistImage2:', isExistImage2.$metadata.httpStatusCode === 200)
|
||||
//견적서2 번 이미지
|
||||
const isExistImage2 = await s3.send(
|
||||
new GetObjectCommand({
|
||||
Bucket,
|
||||
Key: `Drawing/${objectNo}_${planNo}_1.png`,
|
||||
}),
|
||||
)
|
||||
|
||||
//견적서1,2 번 이미지 둘다 있어야함
|
||||
if (isExistImage1.$metadata.httpStatusCode === 200 && isExistImage2.$metadata.httpStatusCode === 200) {
|
||||
//견적서1 번 이미지 복사
|
||||
const copyCommand = new CopyObjectCommand({
|
||||
Bucket,
|
||||
CopySource: encodeURI(`${Bucket}/Drawing/${objectNo}_${planNo}_1.png`),
|
||||
@ -52,8 +53,7 @@ export async function POST(req) {
|
||||
|
||||
responseArray.push(response, response2)
|
||||
return NextResponse.json({ message: '견적서 이미지 복사 성공', responseArray }, { status: 200 })
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
return NextResponse.json({ message: '견적서 이미지 복사 실패' }, { status: 500 })
|
||||
} else {
|
||||
return NextResponse.json({ message: '견적서 이미지 복사 실패(존재하지 않는 이미지)', responseArray }, { status: 400 })
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user