الحدود والتحقق
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
reject files that are too big or the wrong kind.
الموضوعات المخطط لها
- Set size limits in configuration (
spring.servlet.multipart.max-file-sizeandmax-request-size); verify property names for your version. - An oversized upload gives
413 Content Too Large(verify wording) or a mapped error; handle it with a clear message. - Check the declared content type against an allow-list (
image/png,image/jpeg), and reject empty files. - The declared type can lie; for stronger checks, inspect the first bytes (file signature) before accepting.
- Return
400or415for wrong type, with a Problem Details body.
تفاصيل المخطط المبدئي
عرض عملي
spring.servlet.multipart.max-file-size: 5MB
spring.servlet.multipart.max-request-size: 6MBاختبر فهمك
Why check size in configuration?
أظهر الإجابة
So huge uploads are stopped early.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.