Merge branch 'main' into feature-ssulbox

This commit is contained in:
skkim committed 2026-08-12 15:42:15 +09:00
commit cdddb913a0
10 files changed
+763 -62

No files matched your search

+9 -14
View File
@@ -37,6 +37,7 @@ import {
ContentType,
LikeToggleResponse,
} from '../types/api';
import { uploadImagesSequentially } from './imageUpload.ts';
export const API_URL = import.meta.env.VITE_API_URL || 'http://40.82.133.44';
console.log('[API] API_URL:', API_URL);
@@ -718,18 +719,10 @@ export async function uploadImages(
imageUrls: ImageUrlItem[],
files: File[]
): Promise<ImageUploadResponse> {
const formData = new FormData();
// URL 이미지들을 images_json으로 전달
if (imageUrls.length > 0) {
formData.append('images_json', JSON.stringify(imageUrls));
}
// 파일들을 files로 전달
files.forEach((file) => {
formData.append('files', file);
});
return uploadImagesSequentially(imageUrls, files, postImageUpload);
}
async function postImageUpload(formData: FormData): Promise<ImageUploadResponse> {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), IMAGE_UPLOAD_TIMEOUT);
@@ -740,19 +733,21 @@ export async function uploadImages(
signal: controller.signal,
});
clearTimeout(timeoutId);
if (!response.ok) {
if (response.status === 413) {
throw new Error('이미지 파일이 너무 커서 업로드할 수 없습니다. 더 작은 이미지를 선택해주세요.');
}
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
} catch (error) {
clearTimeout(timeoutId);
if (error instanceof Error && error.name === 'AbortError') {
throw new Error('이미지 업로드 시간이 초과되었습니다. 다시 시도해주세요.');
}
throw error;
} finally {
clearTimeout(timeoutId);
}
}