Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] fix: S3 이미지 업로드 수정 #582

Merged
merged 3 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"@fun-eat/design-system": "^0.3.11",
"@tanstack/react-query": "^4.32.6",
"@tanstack/react-query-devtools": "^4.32.6",
"browser-image-compression": "^2.0.2",
"dayjs": "^1.11.9",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/hooks/common/useImageUploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useState } from 'react';
import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';

const MAX_SIZE = 5 * 1024 * 1024;
const client = new S3Client({});
const client = new S3Client({ region: 'ap-northeast-2' });
const IMAGE_ENVIRONMENT = window.location.href.includes('dev') ? 'dev' : 'prod';

const useImageUploader = () => {
Expand All @@ -31,8 +31,8 @@ const useImageUploader = () => {
Body: imageFile,
});

setPreviewImage(URL.createObjectURL(imageFile));
await client.send(image);
setPreviewImage(URL.createObjectURL(imageFile));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

순서를 바꾼 이유는 무엇인가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

업로드 실패시 미리보기도 안나오게 했습니다!

setImageUrl(`${process.env.CLOUDFRONT_URL}/${IMAGE_ENVIRONMENT}/${imageFile.name}`);
} catch (error) {
alert('이미지 업로드에 실패했습니다. 다시 시도해주세요.');
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import { SvgSprite } from './components/Common';
import router from './router';
import GlobalStyle from './styles';

ReactGA.initialize(process.env.GOOGLE_ANALYTICS_ID as string);
const initializeReactGA = () => {
if (process.env.NODE_ENV === 'production') {
ReactGA.initialize(process.env.GOOGLE_ANALYTICS_ID as string);
}
};
initializeReactGA();

const main = async () => {
if (process.env.NODE_ENV === 'development') {
Expand Down
12 changes: 0 additions & 12 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5350,13 +5350,6 @@ browser-assert@^1.2.1:
resolved "https://registry.yarnpkg.com/browser-assert/-/browser-assert-1.2.1.tgz#9aaa5a2a8c74685c2ae05bfe46efd606f068c200"
integrity sha512-nfulgvOR6S4gt9UKCeGJOuSGBPGiFT6oQ/2UBnvTY/5aQ1PnksW72fhZkM30DzoRRv2WpwZf1vHHEr3mtuXIWQ==

browser-image-compression@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/browser-image-compression/-/browser-image-compression-2.0.2.tgz#4d5ef8882e9e471d6d923715ceb9034499d14eaa"
integrity sha512-pBLlQyUf6yB8SmmngrcOw3EoS4RpQ1BcylI3T9Yqn7+4nrQTXJD4sJDe5ODnJdrvNMaio5OicFo75rDyJD2Ucw==
dependencies:
uzip "0.20201231.0"

browserify-zlib@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/browserify-zlib/-/browserify-zlib-0.1.4.tgz#bb35f8a519f600e0fa6b8485241c979d0141fb2d"
Expand Down Expand Up @@ -11553,11 +11546,6 @@ uuid@^9.0.0:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5"
integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==

[email protected]:
version "0.20201231.0"
resolved "https://registry.yarnpkg.com/uzip/-/uzip-0.20201231.0.tgz#9e64b065b9a8ebf26eb7583fe8e77e1d9a15ed14"
integrity sha512-OZeJfZP+R0z9D6TmBgLq2LHzSSptGMGDGigGiEe0pr8UBe/7fdflgHlHBNDASTXB5jnFuxHpNaJywSg8YFeGng==

v8-to-istanbul@^9.0.0, v8-to-istanbul@^9.0.1:
version "9.1.0"
resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz#1b83ed4e397f58c85c266a570fc2558b5feb9265"
Expand Down