강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

terecal님의 프로필 이미지
terecal

작성한 질문수

React로 NodeBird SNS 만들기

8-15. 프론트, 백엔드 쿠키 통일하기

이미지 서빙이 안되서여

작성

·

158

0

삭제된 글입니다

답변 7

1

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

images[0].src같은게 null인것같은데요? 등록할 때부터 src가 제대로 등록되지 않은 것 같아요. 디비 확인해보세요.

0

terecal님의 프로필 이미지
terecal
질문자

db에 null 로 입력되어 있어여 입력이 잘못되었나봐여

routes/user.js에서 찾아보면 될까여

0

terecal님의 프로필 이미지
terecal
질문자

아마존 s3 업로드 폴더 이름이 문제가 될수도 있나여? 아직도 해결 못하고 있어요 ;

0

terecal님의 프로필 이미지
terecal
질문자

// front/components/PostImages.js

import React, { useCallback, useState } from 'react';
import PropTypes from 'prop-types';
import { Icon } from 'antd';
import ImagesZoom from './ImagesZoom';


const PostImages = ({ images }) => {

	console.log("images : " , images);
	
	
	const [showImagesZoom, setShowImagesZoom] = useState(false);
	const onZoom = useCallback(() => {
		setShowImagesZoom(true);
	}, []);
	const onClose = useCallback(() => {
		setShowImagesZoom(false);
	}, []);

	if (images.length === 1) {
		return (
			<>
				<img src={images[0].src} onClick={onZoom} />
				{showImagesZoom && <ImagesZoom images={images} onClose={onClose} />}
			</>	
		);
	}

	if (images.length === 2) {
		return (
			<>
				<div>
					<img src={images[0].src} width="50%" onClick={onZoom} />
					<img src={images[1].src} width="50%" onClick={onZoom} />
					{showImagesZoom && <ImagesZoom images={images} onClose={onClose} />}
				</div>
			</>
		);
	}

	return (
		<>
			<div>
				<img src={images[0].src} width="50%" onClick={onZoom} />
				<div style={{ display: 'inline-block', width: '50%', textAlign: 'center', verticalAlign: 'middle' }} onClick={onZoom}  >
					<Icon type="plus" />
					<br />
					{images.length - 1}
					개의 사진 더보기
                </div>
			</div>
			{showImagesZoom && <ImagesZoom images={images} onClose={onClose} />}
		</>
	);
};


PostImages.propTypes = {
	images: PropTypes.arrayOf(PropTypes.shape({
		src: PropTypes.string,
	})).isRequired,
};


export default PostImages;

0

terecal님의 프로필 이미지
terecal
질문자

업로드는는 된거 같은데 access denied 는 아닌거 같아여 다운로드는 받아져여

0

terecal님의 프로필 이미지
terecal
질문자

네트워크 탭에는 null로 찍히는거 같아여 잘못 올린걸까여?

0

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

AWS S3에 이미지 업로드 하셨나요? 네트워크 탭에서 이미지 관련 요청들 뭐라고 뜨는지 보여주세요.

terecal님의 프로필 이미지
terecal

작성한 질문수

질문하기