Skip to content

Commit

Permalink
[ fix ] 서버리스 api 줄이기 위해 통합
Browse files Browse the repository at this point in the history
  • Loading branch information
myeongheonhong committed Aug 23, 2023
1 parent 27f8f28 commit 090c6ae
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 53 deletions.
17 changes: 0 additions & 17 deletions api/wishes/getPresignedURL.ts

This file was deleted.

13 changes: 0 additions & 13 deletions api/wishes/uploadPresignedURL.ts

This file was deleted.

28 changes: 28 additions & 0 deletions api/wishes/wishesAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PATH from '../../constant/path';
import { client } from '../common/axios';
import { WishesDataType } from '@/types/wishes/wishesDataType';
import { PARSING_TAG_KEY } from '@/constant/parsingTagKey';
import axios from 'axios';

export const createWishesLink = async (wishesData: WishesDataType) => {
const accessToken = localStorage.getItem('accessToken');
Expand Down Expand Up @@ -89,3 +90,30 @@ export const getUserAccount = async () => {
});
return data?.data;
};

export const getPresignedURL = async (fileName: string | undefined) => {
const accessToken = localStorage.getItem('accessToken');
const data = await client.get(
`${PATH.API}/${PATH.V1}/${PATH.FILE}?${PATH.FILE_NAME}=${fileName}`,
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
},
},
);

return data;
};

export const uploadPresignedURL = async (signedURL: string, file: File | Blob | null) => {
console.log(decodeURIComponent(signedURL));
const data = await axios.put(signedURL, file, {
headers: {
'Content-Type': file?.type,
},
});

console.log(data);
return data;
};
3 changes: 1 addition & 2 deletions hooks/wishes/useUploadItemInfo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getPresignedURL } from '@/api/wishes/getPresignedURL';
import { uploadPresignedURL } from '@/api/wishes/uploadPresignedURL';
import { getPresignedURL, uploadPresignedURL } from '@/api/wishes/wishesAPI';
import { QUERY_KEY } from '@/constant/queryKey';
import { useEffect, useState } from 'react';
import { useMutation, useQuery } from 'react-query';
Expand Down
21 changes: 0 additions & 21 deletions hooks/wishes/useUploadItemInfo.tsx

This file was deleted.

0 comments on commit 090c6ae

Please sign in to comment.