-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
962 additions
and
494 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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import axiosInstance from '@/lib/axiosInstance'; | ||
import sessionStorage from './storage/sessionStorage'; | ||
import { ImageRequest, ImageResponse } from './type/Image'; | ||
|
||
/*** 이미지 업로드 | ||
* 프로젝트에 저장하는 이미지들은 이 엔드포인트를 통해 업로드한 후 URL을 획득하여 사용합니다. | ||
*/ | ||
export const postImagesUpload = async ( | ||
data: ImageRequest | ||
): Promise<ImageResponse> => { | ||
// create formdata | ||
const formData = new FormData(); | ||
formData.append('image', data.file); | ||
|
||
const URL = `/images/upload`; | ||
console.log('POST - postImagesUpload(): ', URL); | ||
|
||
try { | ||
const res = await axiosInstance.post(URL, formData); | ||
|
||
if (res.status === 200 || res.status === 201) { | ||
const resData = res.data as ImageResponse; | ||
sessionStorage.setItem(`postImagesUpload`, resData); | ||
return resData; | ||
} else { | ||
throw new Error( | ||
`Failed to postImagesUpload() res.status: ${res.status}, res.data: ${res.data}` | ||
); | ||
} | ||
} catch (error) { | ||
throw error; | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.