- 한 번에 여러 이미지 업로드 (드래그/선택, 개별 이름 수정/제거) - 다중 선택 삭제 모드 (선택 모드 토글, 전체 선택) - 커스텀 확인 다이얼로그 (네이티브 confirm 대체) - 이미지 이름 unique 제약 + 입력 시 실시간 중복/빈 값 검증 - 백엔드 다중 업로드 시 사전 중복 체크 - 카드에서 URL 표시 제거 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
34 lines
834 B
JavaScript
34 lines
834 B
JavaScript
import { S3Client, PutObjectCommand, DeleteObjectCommand } from '@aws-sdk/client-s3';
|
|
|
|
export const s3 = new S3Client({
|
|
endpoint: process.env.S3_ENDPOINT,
|
|
region: 'auto',
|
|
credentials: {
|
|
accessKeyId: process.env.S3_ACCESS_KEY,
|
|
secretAccessKey: process.env.S3_SECRET_KEY,
|
|
},
|
|
forcePathStyle: true,
|
|
});
|
|
|
|
export const S3_BUCKET = process.env.S3_BUCKET;
|
|
export const S3_PUBLIC_URL = process.env.S3_PUBLIC_URL;
|
|
|
|
export async function uploadObject(key, body, contentType) {
|
|
await s3.send(new PutObjectCommand({
|
|
Bucket: S3_BUCKET,
|
|
Key: key,
|
|
Body: body,
|
|
ContentType: contentType,
|
|
}));
|
|
}
|
|
|
|
export async function deleteObject(key) {
|
|
await s3.send(new DeleteObjectCommand({
|
|
Bucket: S3_BUCKET,
|
|
Key: key,
|
|
}));
|
|
}
|
|
|
|
export function getPublicUrl(key) {
|
|
return `${S3_PUBLIC_URL}/${S3_BUCKET}/${key}`;
|
|
}
|