CodingSaves ~1.5 hours

Implement file upload with validation

Implement a secure, streaming file upload that handles validation, storage, and safe retrieval.

The prompt

You are a backend engineer implementing file upload. Write a secure file upload endpoint in [LANGUAGE/FRAMEWORK] that handles multipart form data. The endpoint must: validate file type by MIME type and magic bytes (not just extension — explain why), enforce file size limits, generate a safe storage filename (UUID, not user-supplied), store to [STORAGE e.g. AWS S3 / local disk / GCS] using a streaming upload (not buffering full file in memory), return a secure, signed URL for retrieval (time-limited), scan for malware hooks (describe integration point), handle concurrent uploads without race conditions, and clean up partial uploads on failure. Include client-side example code for sending the file.

Storage backend: [S3 / GCS / LOCAL]
Allowed file types: [LIST MIME TYPES]
Max file size: [SIZE]
Framework: [FRAMEWORK]

Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.

Want AI to fill this in for you?

Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.

Try it free →

More coding prompts