أين نخزّن الملفات
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
pick a safe storage location and naming.
الموضوعات المخطط لها
- Never store uploads inside the JAR or the project folder; they vanish on redeploy and the folder may be public.
- Use a configured directory outside the application (
app.storage.dir), a mounted volume, or object storage such as S3 later (MID-056). - Generate the stored name yourself, for example a UUID, and keep the original name only as metadata.
- Keep a record (ID, original name, content type, size, stored name) in your data model.
- Do not rely on the local disk if you run several instances.
تفاصيل المخطط المبدئي
عرض عملي
record ImageRecord(id, productId, originalName, contentType, size, storedName); the file is stored as <dir>/<uuid>.
اختبر فهمك
Who chooses the stored file name?
أظهر الإجابة
The server, never the client.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.