Skip to content

Commit 511e7bb

Browse files
authored
πŸ› presigned url λ°œκΈ‰ μ‹œ 토큰을 λ°˜λ“œμ‹œ ν¬ν•¨ν•˜λ„λ‘ μˆ˜μ • (#47)
1 parent 37f0181 commit 511e7bb

7 files changed

Lines changed: 29 additions & 5 deletions

File tree

β€Žsrc/feature/application/application/application-query.tsβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,18 @@ export const useApplicationQuery = ({
5454
eventId,
5555
walletAddress,
5656
imageFile,
57+
token,
5758
}: {
5859
eventId: string;
5960
walletAddress: string;
6061
imageFile: File;
62+
token: string;
6163
}) => {
6264
return await applicationUsecase.submitApplication({
6365
eventId,
6466
walletAddress,
6567
imageFile,
68+
token,
6669
});
6770
},
6871
onSuccess: (response) => {

β€Žsrc/feature/application/usecase/application-usecase.tsβ€Ž

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type ApplicationUsecase = {
1313
eventId: string;
1414
walletAddress: string;
1515
imageFile: File;
16+
token: string;
1617
}): UsecaseResponse<null>;
1718
};
1819

@@ -45,10 +46,11 @@ export const implApplicationUsecase = ({
4546
return { type: 'error', code: err.code, message: err.message };
4647
},
4748

48-
submitApplication: async ({ eventId, walletAddress, imageFile }) => {
49+
submitApplication: async ({ eventId, walletAddress, imageFile, token }) => {
4950
const presignedResp = await fileUsecase.getUploadPresignedUrl({
5051
fileName: imageFile.name,
5152
fileType: 'REVIEW',
53+
contentType: imageFile.type,
5254
});
5355
if (presignedResp.type === 'error') {
5456
return presignedResp;
@@ -64,6 +66,7 @@ export const implApplicationUsecase = ({
6466

6567
const { status, data } = await api['POST /api/applications']({
6668
body: { eventId, walletAddress, imageKey: presignedResp.data.s3Key },
69+
token,
6770
});
6871
if (status === 200) {
6972
return { type: 'success', data: null };

β€Žsrc/feature/file/usecase/file-usecase.tsβ€Ž

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type FileUsecase = {
88
getUploadPresignedUrl(params: {
99
fileName: string;
1010
fileType: FileType;
11+
contentType: string;
1112
}): UsecaseResponse<S3UploadResponse>;
1213
uploadFile(params: {
1314
presignedUrl: string;
@@ -22,9 +23,9 @@ export const implFileUsecase = ({
2223
api: Apis;
2324
storageApi: StorageApis;
2425
}): FileUsecase => ({
25-
getUploadPresignedUrl: async ({ fileName, fileType }) => {
26+
getUploadPresignedUrl: async ({ fileName, fileType, contentType }) => {
2627
const { status, data } = await api['POST /api/s3']({
27-
body: { fileName, fileType },
28+
body: { fileName, fileType, contentType },
2829
});
2930
if (status === 200) {
3031
return { type: 'success', data: data as S3UploadResponse };

β€Žsrc/infrastructure/api/apis/local-server/apis.tsβ€Ž

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,18 @@ export const getLocalServerApis = ({
138138
path: 'api/s3',
139139
body,
140140
}),
141-
'POST /api/applications': ({ body }: { body: ApplicationCreateRequest }) =>
142-
callWithoutToken<SuccessResponse<null>>({
141+
'POST /api/applications': ({
142+
body,
143+
token,
144+
}: {
145+
body: ApplicationCreateRequest;
146+
token: string;
147+
}) =>
148+
callWithToken<SuccessResponse<null>>({
143149
method: 'POST',
144150
path: 'api/applications',
145151
body,
152+
token,
146153
}),
147154

148155
// Event

β€Žsrc/infrastructure/api/apis/local-server/schemas.tsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export type S3FileType = 'REVIEW' | 'STORE';
9090
export type S3UploadRequest = {
9191
fileName: string;
9292
fileType: S3FileType;
93+
contentType: string;
9394
};
9495

9596
export type S3UploadResponse = {

β€Žsrc/mocks/s3/schemas.tsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export type S3FileType = 'REVIEW' | 'STORE';
33
export type S3UploadRequest = {
44
fileName: string;
55
fileType: S3FileType;
6+
contentType: string;
67
};
78

89
export type S3UploadResponse = {

β€Žsrc/widgets/application/ui/submit-form.tsxβ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useParams } from 'react-router';
44
import { applicationFormPresenter } from '@/feature/application/presenter/application-form-presenter';
55
import { applicationInputPresenter } from '@/feature/application/presenter/application-input-presenter';
66
import { QueryContext } from '@/feature/shared/context/query-context';
7+
import { TokenContext } from '@/feature/shared/context/token-context';
78
import { useGuardContext } from '@/feature/shared/context/use-gaurd-context';
89
import { Button } from '@/widgets/common/ui/button';
910
import {
@@ -32,6 +33,7 @@ export const SubmitForm = () => {
3233
}>();
3334

3435
const { applicationQuery } = useGuardContext(QueryContext);
36+
const { token } = useGuardContext(TokenContext);
3537

3638
const { store } = applicationQuery.useGetStore({ storeId: storeId ?? '' });
3739
const { event } = applicationQuery.useGetEvent({ eventId: eventId ?? '' });
@@ -133,10 +135,16 @@ export const SubmitForm = () => {
133135
return;
134136
}
135137

138+
if (token === null) {
139+
setResponseMessage('둜그인이 ν•„μš”ν•©λ‹ˆλ‹€.');
140+
return;
141+
}
142+
136143
submitApplication({
137144
eventId,
138145
walletAddress: inputStates.walletAddress.value,
139146
imageFile: inputStates.imageFile.value,
147+
token,
140148
});
141149
};
142150

0 commit comments

Comments
Β (0)