diff --git a/packages/web/src/components/ModalPopup/ModalMypageModify.tsx b/packages/web/src/components/ModalPopup/ModalMypageModify.tsx index dcd267021..b0ad3336a 100644 --- a/packages/web/src/components/ModalPopup/ModalMypageModify.tsx +++ b/packages/web/src/components/ModalPopup/ModalMypageModify.tsx @@ -70,23 +70,23 @@ const ButtonProfileImage = () => { type: image.type, }, }); - if (data.url && data.fields) { - const formData = new FormData(); - for (const key in data.fields) { - formData.append(key, data.fields[key]); - } - formData.append("file", image); - const res = await axiosOri.post(data.url, formData); - if (res.status === 204) { - const data2 = await axios({ - url: "/users/editProfileImg/done", - method: "get", - }); - if (data2?.result) { - fetchLoginInfo(); - setProfileAlert("SUCCESS"); - return; - } + if (data.url) { + await axiosOri({ + url: data.url, + method: "put", + headers: { + "Content-Type": image.type, + }, + data: image, + }); + const data2 = await axios({ + url: "/users/editProfileImg/done", + method: "get", + }); + if (data2?.result) { + fetchLoginInfo(); + setProfileAlert("SUCCESS"); + return; } } setProfileAlert("FAIL"); diff --git a/packages/web/src/hooks/chat/useSendMessage.tsx b/packages/web/src/hooks/chat/useSendMessage.tsx index 401633095..a8f043592 100644 --- a/packages/web/src/hooks/chat/useSendMessage.tsx +++ b/packages/web/src/hooks/chat/useSendMessage.tsx @@ -43,18 +43,19 @@ export default ( if (!file) throw new Error(); isSendingMessage.current = true; - const { url, fields, id } = await axios({ + const { url, id } = await axios({ url: "chats/uploadChatImg/getPUrl", method: "post", data: { roomId, type: file.type }, }); - if (!url || !fields || !id) throw new Error(); + if (!url || !id) throw new Error(); - const formData = new FormData(); - for (const key in fields) formData.append(key, fields[key]); - formData.append("file", file); - const { status: s3Status } = await axiosOri.post(url, formData); - if (s3Status !== 204) throw new Error(); + await axiosOri({ + url, + method: "put", + data: file, + headers: { "Content-Type": file.type }, + }); const { result } = await axios({ url: "chats/uploadChatImg/done", diff --git a/packages/web/src/hooks/useTaxiAPI/useAxios.tsx b/packages/web/src/hooks/useTaxiAPI/useAxios.tsx index 5204bda8d..2a111153d 100644 --- a/packages/web/src/hooks/useTaxiAPI/useAxios.tsx +++ b/packages/web/src/hooks/useTaxiAPI/useAxios.tsx @@ -42,8 +42,6 @@ const useAxios = () => { `/login?redirect=${encodeURIComponent(currentPath)}` )}` ); - } else if (res.status !== 200) { - throw new Error("Status is not 200!"); } else { if (onSuccess) onSuccess(res.data); return res.data;