Skip to content

Commit

Permalink
[fix]minioのディレクトリをyear/advertisements/filenameに変更
Browse files Browse the repository at this point in the history
  • Loading branch information
Kubosaka committed Jul 28, 2024
1 parent e4dd3df commit aa61164
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ interface ModalProps {
id: React.ReactNode;
sponsorActivitiesViewItem: SponsorActivityView;
isDelete: boolean;
year: string;
}

const DetailModal: FC<ModalProps> = (props) => {
const { year } = props;
const [isChange, setIsChange] = useState<boolean>(false);
const [sponsorActivitiesView, setSponsorActivitiesView] = useState<SponsorActivityView>(
props.sponsorActivitiesViewItem,
Expand Down Expand Up @@ -48,6 +50,7 @@ const DetailModal: FC<ModalProps> = (props) => {
setSponsorActivitiesView={setSponsorActivitiesView}
id={props.id}
setIsChange={setIsChange}
year={year}
/>
)}
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ interface ModalProps {
children?: React.ReactNode;
id: React.ReactNode;
sponsorActivitiesViewItem: SponsorActivityView;
year: string;
setIsChange: (isChange: boolean) => void;
setSponsorActivitiesView: (sponsorActivitiesView: SponsorActivityView) => void;
}

const DetailPage2: FC<ModalProps> = (props) => {
const { year } = props;
const toPage1 = () => {
props.setPageNum(1);
};
Expand Down Expand Up @@ -68,7 +70,7 @@ const DetailPage2: FC<ModalProps> = (props) => {
sponsorActivityInformations.map((activityInformation) => {
const bucketName = activityInformation.bucketName;
const fileName = activityInformation.fileName;
return `${process.env.NEXT_PUBLIC_MINIO_ENDPONT}/${bucketName}/${fileName}`;
return `${process.env.NEXT_PUBLIC_MINIO_ENDPONT}/${bucketName}/${year}/advertisements/${fileName}`;
});

const download = async (url: string, fileName: string) => {
Expand Down Expand Up @@ -377,6 +379,7 @@ const DetailPage2: FC<ModalProps> = (props) => {
sponsorActivityInformations={sponsorActivityInformations}
setSponsorActivityInformations={setSponsorActivityInformations}
setIsChange={props.setIsChange}
year={year}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface ModalProps {
children?: React.ReactNode;
id: number;
ActivityInformationId: number;
year: string;
sponsorActivityInformations?: SponsorActivityInformation[];
setSponsorActivityInformations: (
sponsorActivityInformations: SponsorActivityInformation[],
Expand All @@ -19,6 +20,7 @@ interface ModalProps {
}

const UplaodFileModal: FC<ModalProps> = (props) => {
const { year } = props;
const fileInputRef = useRef<HTMLInputElement>(null);
const [imageFile, setImageFile] = useState<File | null>(null);
const [preview, setPreview] = useState({ uploadImageURL: '', type: '' });
Expand Down Expand Up @@ -74,8 +76,9 @@ const UplaodFileModal: FC<ModalProps> = (props) => {
formData.append('file', imageFile);
const fileName = imageFile?.name || '';
formData.append('fileName', fileName);
formData.append('year', year);

const response = await fetch('/api/minio', {
const response = await fetch('/api/advertisements', {
method: 'POST',
body: formData,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}

const bucketName = 'finansu';
const fileName = files.file[0].originalFilename;
const year = fields.year && fields.year[0];
const fileName = `${year}/advertisements/${files.file[0].originalFilename}`;
const file = files.file[0];
const mimetype = file.mimetype;
const metaData = {
Expand Down
1 change: 1 addition & 0 deletions view/next-project/src/pages/sponsoractivities/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ export default function SponsorActivities(props: Props) {
setIsOpen={setIsOpen}
sponsorActivitiesViewItem={sponsorActivitiesItem}
isDelete={false}
year={selectedYear}
/>
)}
</MainLayout>
Expand Down

0 comments on commit aa61164

Please sign in to comment.