Skip to content

Commit

Permalink
Merge pull request #20 from 0xC0FFE2/master
Browse files Browse the repository at this point in the history
feat : add fast paste upload
  • Loading branch information
0xC0FFE2 authored Dec 18, 2024
2 parents 7f15488 + 69ce692 commit 2cfae25
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/pages/Uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,25 @@ const FileUploader = () => {
await verifyAndUpload(formData);
};

const handlePaste = (e) => {
const items = e.clipboardData.items;

for (let i = 0; i < items.length; i++) {
if (items[i].type.startsWith('image/')) {
const pastedFile = items[i].getAsFile();
setFile(pastedFile);
toast.info('이미지가 클립보드에서 붙여넣기되었습니다.');
return;
}
}
toast.error('붙여넣기된 내용에 이미지가 없습니다.');
};

return (
<div className="max-w-4xl mx-auto p-6 bg-white shadow-lg rounded-lg mt-16">
<div
className="max-w-4xl mx-auto p-6 bg-white shadow-lg rounded-lg mt-16"
onPaste={handlePaste}
>
<h2 className="text-2xl font-semibold text-gray-800 mb-6">파일 업로드</h2>
<form onSubmit={handleSubmit} className="space-y-4">
<FileInput onFileChange={handleFileChange} />
Expand All @@ -83,4 +100,4 @@ const FileUploader = () => {
);
};

export default FileUploader;
export default FileUploader;

0 comments on commit 2cfae25

Please sign in to comment.