diff --git a/api/wishes/getPresignedURL.ts b/api/wishes/getPresignedURL.ts deleted file mode 100644 index d4d85252..00000000 --- a/api/wishes/getPresignedURL.ts +++ /dev/null @@ -1,17 +0,0 @@ -import PATH from '@/constant/path'; -import { client } from '../common/axios'; - -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; -}; diff --git a/api/wishes/uploadPresignedURL.ts b/api/wishes/uploadPresignedURL.ts deleted file mode 100644 index 7af5fff1..00000000 --- a/api/wishes/uploadPresignedURL.ts +++ /dev/null @@ -1,13 +0,0 @@ -import axios from 'axios'; - -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; -}; diff --git a/api/wishes/wishesAPI.ts b/api/wishes/wishesAPI.ts index 9787db6c..c188a133 100644 --- a/api/wishes/wishesAPI.ts +++ b/api/wishes/wishesAPI.ts @@ -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'); @@ -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; +}; diff --git a/hooks/wishes/useUploadItemInfo.ts b/hooks/wishes/useUploadItemInfo.ts index 68724eb1..eb27cb06 100644 --- a/hooks/wishes/useUploadItemInfo.ts +++ b/hooks/wishes/useUploadItemInfo.ts @@ -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'; diff --git a/hooks/wishes/useUploadItemInfo.tsx b/hooks/wishes/useUploadItemInfo.tsx deleted file mode 100644 index 6f602cec..00000000 --- a/hooks/wishes/useUploadItemInfo.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { useState } from 'react'; - -export default function useUploadItemInfo() { - const [imageFile, setImageFile] = useState(null); - const [previewImage, setPreviewImage] = useState(''); - - function uploadImageFile(e: React.ChangeEvent) { - const imageFile = e.target.files && e.target.files[0]; - - if (imageFile) { - setImageFile(imageFile); - const reader = new FileReader(); - imageFile && reader.readAsDataURL(imageFile); - reader.onloadend = () => { - setPreviewImage(reader.result as string); - }; - } - } - - return { imageFile, previewImage, setPreviewImage, uploadImageFile }; -}