Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#697 AWS-SDK V3으로 마이그레이션 #698

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions packages/web/src/components/ModalPopup/ModalMypageModify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
15 changes: 8 additions & 7 deletions packages/web/src/hooks/chat/useSendMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions packages/web/src/hooks/useTaxiAPI/useAxios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down