견적서 복사 로직 수정 #96
@ -12,28 +12,29 @@ const s3 = new S3Client({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export async function POST(req) {
|
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(
|
//견적서1 번 이미지
|
||||||
// new GetObjectCommand({
|
const isExistImage1 = await s3.send(
|
||||||
// Bucket,
|
new GetObjectCommand({
|
||||||
// Key: `Drawing/${objectNo}_${planNo}_1.png`,
|
Bucket,
|
||||||
// }),
|
Key: `Drawing/${objectNo}_${planNo}_1.png`,
|
||||||
// )
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
// const isExistImage2 = await s3.send(
|
//견적서2 번 이미지
|
||||||
// new GetObjectCommand({
|
const isExistImage2 = await s3.send(
|
||||||
// Bucket,
|
new GetObjectCommand({
|
||||||
// Key: `Drawing/${objectNo}_${planNo}_1.png`,
|
Bucket,
|
||||||
// }),
|
Key: `Drawing/${objectNo}_${planNo}_1.png`,
|
||||||
// )
|
}),
|
||||||
|
)
|
||||||
// console.log('🚀 ~ isExistImage1:', isExistImage1.$metadata.httpStatusCode === 200)
|
|
||||||
// console.log('🚀 ~ isExistImage2:', isExistImage2.$metadata.httpStatusCode === 200)
|
|
||||||
|
|
||||||
|
//견적서1,2 번 이미지 둘다 있어야함
|
||||||
|
if (isExistImage1.$metadata.httpStatusCode === 200 && isExistImage2.$metadata.httpStatusCode === 200) {
|
||||||
|
//견적서1 번 이미지 복사
|
||||||
const copyCommand = new CopyObjectCommand({
|
const copyCommand = new CopyObjectCommand({
|
||||||
Bucket,
|
Bucket,
|
||||||
CopySource: encodeURI(`${Bucket}/Drawing/${objectNo}_${planNo}_1.png`),
|
CopySource: encodeURI(`${Bucket}/Drawing/${objectNo}_${planNo}_1.png`),
|
||||||
@ -52,8 +53,7 @@ export async function POST(req) {
|
|||||||
|
|
||||||
responseArray.push(response, response2)
|
responseArray.push(response, response2)
|
||||||
return NextResponse.json({ message: '견적서 이미지 복사 성공', responseArray }, { status: 200 })
|
return NextResponse.json({ message: '견적서 이미지 복사 성공', responseArray }, { status: 200 })
|
||||||
} catch (error) {
|
} else {
|
||||||
console.error(error)
|
return NextResponse.json({ message: '견적서 이미지 복사 실패(존재하지 않는 이미지)', responseArray }, { status: 400 })
|
||||||
return NextResponse.json({ message: '견적서 이미지 복사 실패' }, { status: 500 })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user