feat: 구글 맵 컨버트 기능 수정
This commit is contained in:
parent
2492b45a66
commit
9a9fa522f9
Binary file not shown.
@ -1,4 +1,14 @@
|
|||||||
import { NextResponse } from 'next/server'
|
import { NextResponse } from 'next/server'
|
||||||
|
import { S3Client, PutObjectCommand, DeleteObjectCommand } from '@aws-sdk/client-s3'
|
||||||
|
|
||||||
|
const Bucket = process.env.AMPLIFY_BUCKET
|
||||||
|
const s3 = new S3Client({
|
||||||
|
region: process.env.AWS_REGION,
|
||||||
|
credentials: {
|
||||||
|
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
||||||
|
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
export async function GET(req) {
|
export async function GET(req) {
|
||||||
try {
|
try {
|
||||||
@ -19,7 +29,7 @@ export async function GET(req) {
|
|||||||
|
|
||||||
/** 변경된 이미지를 S3에 업로드 */
|
/** 변경된 이미지를 S3에 업로드 */
|
||||||
const Body = Buffer.from(data)
|
const Body = Buffer.from(data)
|
||||||
const Key = `map/${file.name}`
|
const Key = `maps/${fileNm}`
|
||||||
const ContentType = 'image/png'
|
const ContentType = 'image/png'
|
||||||
|
|
||||||
await s3.send(
|
await s3.send(
|
||||||
@ -46,7 +56,7 @@ export async function GET(req) {
|
|||||||
export async function DELETE(req) {
|
export async function DELETE(req) {
|
||||||
try {
|
try {
|
||||||
const searchParams = req.nextUrl.searchParams
|
const searchParams = req.nextUrl.searchParams
|
||||||
const Key = `map/${searchParams.get('fileName')}`
|
const Key = `maps/${searchParams.get('fileName')}`
|
||||||
console.log('🚀 ~ DELETE ~ Key:', Key)
|
console.log('🚀 ~ DELETE ~ Key:', Key)
|
||||||
|
|
||||||
if (!Key) {
|
if (!Key) {
|
||||||
|
|||||||
@ -142,7 +142,7 @@ export function useRefFiles() {
|
|||||||
// url: `${process.env.NEXT_PUBLIC_HOST_URL}/map/convert?q=${queryRef.current.value}&fileNm=${currentCanvasPlan.id}&zoom=20`,
|
// url: `${process.env.NEXT_PUBLIC_HOST_URL}/map/convert?q=${queryRef.current.value}&fileNm=${currentCanvasPlan.id}&zoom=20`,
|
||||||
// })
|
// })
|
||||||
const res = await get({
|
const res = await get({
|
||||||
url: `http://localhost:3000/api/map/upload?q=${queryRef.current.value}&fileNm=${currentCanvasPlan.id}&zoom=20`,
|
url: `http://localhost:3000/api/image/map?q=${queryRef.current.value}&fileNm=${currentCanvasPlan.id}&zoom=20`,
|
||||||
})
|
})
|
||||||
console.log('🚀 ~ handleMapImageDown ~ res:', res)
|
console.log('🚀 ~ handleMapImageDown ~ res:', res)
|
||||||
// setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`)
|
// setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`)
|
||||||
@ -160,16 +160,25 @@ export function useRefFiles() {
|
|||||||
* 배경 이미지 로드를 위한 세팅
|
* 배경 이미지 로드를 위한 세팅
|
||||||
*/
|
*/
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!currentBgImage) {
|
// if (!currentBgImage) {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
console.log('🚀 ~ useEffect ~ currentBgImage:', currentBgImage)
|
console.log('🚀 ~ useEffect ~ currentBgImage:', currentBgImage)
|
||||||
handleBackImageLoadToCanvas(currentBgImage)
|
if (currentBgImage) {
|
||||||
setCurrentCanvasPlan((prev) => ({
|
handleBackImageLoadToCanvas(currentBgImage)
|
||||||
...prev,
|
setCurrentCanvasPlan((prev) => ({
|
||||||
bgImageName: refImage?.name ?? null,
|
...prev,
|
||||||
mapPositionAddress: queryRef.current.value,
|
// bgImageName: refImage?.name ?? null,
|
||||||
}))
|
bgImageName: currentBgImage.split('/').pop(),
|
||||||
|
mapPositionAddress: queryRef.current.value,
|
||||||
|
}))
|
||||||
|
} else {
|
||||||
|
setCurrentCanvasPlan((prev) => ({
|
||||||
|
...prev,
|
||||||
|
bgImageName: null,
|
||||||
|
mapPositionAddress: null,
|
||||||
|
}))
|
||||||
|
}
|
||||||
}, [currentBgImage])
|
}, [currentBgImage])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user