-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[ Feat ] 명함 사진 Presigned URL 연결
- Loading branch information
Showing
7 changed files
with
39 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
import { authAxios } from '@utils/apis'; | ||
import { authAxios, axios } from '@utils/apis'; | ||
|
||
export const businessCardAxios = async (file: File) => { | ||
try { | ||
const formData = new FormData(); | ||
formData.append('businessCardImage', file); | ||
export const businessCardUrlAxios = () => { | ||
return authAxios.get('/v1/image/businesscard'); | ||
}; | ||
|
||
const response = await authAxios.patch('/api/v1/businesscard-image', formData, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data', | ||
}, | ||
}); | ||
return response.data; | ||
} catch (error) { | ||
throw error; | ||
} | ||
export const uploadBusinessCardAxios = async (url: string, file: File) => { | ||
await axios.put(url, file, { | ||
headers: { | ||
'Content-Type': file.type, | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { businessCardAxios } from '../apis/businesscardAxios'; | ||
import { uploadBusinessCardAxios } from '../apis/businesscardAxios'; | ||
|
||
export const useBusinessCardQuery = () => { | ||
const mutation = useMutation({ | ||
mutationFn: (image: File) => businessCardAxios(image), | ||
onError: (error) => { | ||
console.log('명함 업로드 에러: ', error); | ||
}, | ||
return useMutation({ | ||
mutationFn: ({ url, image }: { url: string; image: File }) => uploadBusinessCardAxios(url, image), | ||
}); | ||
|
||
return mutation; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { presignedUrlAxios } from '../apis/profileImageAxios'; | ||
import { profileUrlAxios } from '../apis/profileImageAxios'; | ||
import { businessCardUrlAxios } from '../apis/businesscardAxios'; | ||
|
||
const usePresignedUrl = () => { | ||
export const useProfilePresignedUrl = () => { | ||
const { data } = useQuery({ | ||
queryKey: ['presignedurl'], | ||
queryFn: presignedUrlAxios, | ||
queryKey: ['profile-url'], | ||
queryFn: profileUrlAxios, | ||
}); | ||
return { res: data?.data?.data }; | ||
}; | ||
|
||
export default usePresignedUrl; | ||
export const useBusinessCardPresignedUrl = () => { | ||
const { data } = useQuery({ | ||
queryKey: ['businesscard-url'], | ||
queryFn: businessCardUrlAxios, | ||
}); | ||
return { res: data?.data?.data }; | ||
}; |