0Pricing
Vibe Coding · 강의

파일 읽기와 저장

사용자 파일과 로컬 데이터를 처리합니다.

파일 읽기와 저장은(는) CoddyKit의 무료 Vibe Coding 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Vibe Coding 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Vibe Coding 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Apps Work with Files

Lots of apps deal with files: a user uploads a photo, exports a spreadsheet, or downloads a report. Reading and saving files is a core part of building real tools.

As a vibe coder, you don't need to memorize file APIs. You describe the behavior — 'let the user upload an image and show a preview' — and AI writes the wiring.

Two Kinds of Files

There are two main places files live, and it helps to tell AI which you mean:

  • User files — things a person picks from their device, like a photo or a PDF, usually through an upload button in the browser.
  • Local files — files your code or tool reads from a folder on your computer, common when using Cursor or Claude Code on a project.

Naming which kind keeps the AI from guessing wrong.

Letting Users Upload a File

In a web app, users pick files with an upload input. Here's a prompt that creates a simple, friendly uploader. Notice it names what to do with the file after it's chosen.

Paste this into v0, Bolt or Lovable and you'll get a working upload screen in seconds.

Build a page with a drag-and-drop area where I can
upload an image. After I drop or pick a file, show
a preview of the image and its file name and size.
Use plain HTML, CSS and JavaScript.

Reading Text from a File

When a user uploads a text or CSV file, the browser can read its contents into a string your app can use. AI usually uses a FileReader for this.

This example simulates reading text and counting its lines — the same logic AI would run on real file contents.

const fileContents = 'name,score\nAda,90\nGrace,95';
const lines = fileContents.split('\n');

console.log('Total lines:', lines.length);
console.log('First line:', lines[0]);

Saving and Downloading Files

Apps also create files for users to download — an exported list, a generated report, a saved drawing. In the browser, AI typically builds the content as text and triggers a download.

You just describe it: tell AI what the file should contain and what to name it.

Add an "Export" button that takes the list of tasks
on the page and downloads them as a file named
tasks.txt, one task per line. When clicked, the
browser should save the file to the user's
Downloads folder.

Working with CSV and JSON Files

Two formats show up constantly: CSV (rows and columns, like a spreadsheet) and JSON (labeled data). Apps often import one and export the other.

You don't parse these by hand — you tell AI the format and let it convert. Below, this snippet turns simple data into CSV text, the kind of thing AI generates for an export feature.

const rows = [
  { name: 'Ada', score: 90 },
  { name: 'Grace', score: 95 }
];

const csv = 'name,score\n' +
  rows.map(r => r.name + ',' + r.score).join('\n');

console.log(csv);

Reading Files in Cursor or Claude Code

Agentic tools like Claude Code and Cursor can read files in your project directly. You can point them at a file and ask questions or request changes.

This is huge: instead of copying code around, you just reference the file by name and let the tool open it.

Read data/customers.csv and tell me how many rows
it has and what the column names are. Then create a
script that loads it and prints the 5 customers
with the highest spend.

Handling Big or Messy Files

Real files are messy — extra blank lines, missing values, weird characters. Tell AI to expect this so your app doesn't crash on imperfect input.

Adding 'handle empty rows and missing fields gracefully' to your prompt saves you many bug-fixing rounds later.

Update the CSV importer to skip empty rows, trim
extra spaces, and if a row is missing the score,
set it to 0 instead of crashing. Show me a summary
of how many rows were skipped.

Previewing Before Saving

A polished file feature lets users preview what they're about to import or export before committing. It prevents mistakes and feels professional.

You can layer this on with a follow-up prompt once the basic version works — vibe coding rewards small, steady steps.

Before importing the CSV, show the first 5 rows in
a table so I can confirm it looks right, with an
"Import" and "Cancel" button. Only load the data
after I click Import.

Files Are Just Another Conversation

Whether it's an upload, a download, or reading a project file, the pattern is the same: describe the file, describe what to do with it, describe the edge cases.

You don't need to know FileReader, blobs, or encoding details. You stay focused on the user experience and let AI handle the plumbing.

Keeping Uploads Safe

Files from strangers can be risky — a wrong file type, a giant file that freezes the app, or even something malicious. A polished app sets limits.

Tell AI to validate uploads: allowed types, a maximum size, and a clear message when a file is rejected. This small habit keeps your app stable and friendly.

Only allow image files (jpg, png, webp) up to 5 MB
in the uploader. If someone picks a different type
or a file that's too large, reject it and show a
clear message explaining why. Never crash on a bad
upload.

Quick Check

You're building a web app and you want users to pick a photo from their own device and see a preview. When prompting AI, which detail makes the result most reliable?

Recap: Reading and Saving Files

You learned that apps handle two kinds of files — user uploads and local project files — and that AI can wire up uploads, previews, downloads, and CSV/JSON conversions for you.

You saw how agentic tools read project files directly, and why naming edge cases (empty rows, missing fields) prevents crashes. Next, you'll learn how to store data so it sticks around — from simple local storage to a real database.

자주 묻는 질문

“파일 읽기와 저장” 강의는 무료인가요?

네 — “파일 읽기와 저장” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Vibe Coding 강의 전체를 잠금 해제할 수 있습니다. Vibe Coding 강의에는 총 4개의 강의가 포함되어 있습니다.

“파일 읽기와 저장”에서 뭘 배우나요?

사용자 파일과 로컬 데이터를 처리합니다. 브라우저에서 직접 실행하는 실습 코드로 Vibe Coding을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Vibe Coding을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Vibe Coding은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.

“파일 읽기와 저장” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Vibe Coding 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Vibe Coding 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. API와 대화하기
  2. 파일 읽기와 저장
  3. 간단한 데이터 저장
  4. 보안 정보와 키 처리
← Vibe Coding(으)로 돌아가기