Skip to content

Commit c31b7df

Browse files
authored
♻️ refactor: 이미지 업로드 API 변경 및 폼 데이터 수정
♻️ refactor: 이미지 업로드 API 변경 및 폼 데이터 수정
2 parents 2362a0a + 895e270 commit c31b7df

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/api/postUploadImage.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@ import { api } from './api';
22

33
export default async function uploadImage(file) {
44
const formData = new FormData();
5-
formData.append('image', file);
5+
formData.append('file', file);
6+
formData.append('upload_preset', 'profile_upload');
7+
const cloudName = import.meta.env.VITE_CLOUD_NAME;
68

79
try {
810
const res = await api.post(
9-
`https://api.imgbb.com/1/upload?key=${import.meta.env.VITE_API_KEY}`,
11+
`https://api.cloudinary.com/v1_1/${cloudName}/image/upload`,
1012
formData,
1113
{
1214
headers: {
1315
'Content-Type': 'multipart/form-data',
1416
},
1517
},
1618
);
17-
return res.data.data.url;
19+
return res.data.secure_url;
1820
} catch (error) {
1921
console.error('이미지 업로드 실패', error);
2022
throw error;

0 commit comments

Comments
 (0)