Upload storage and retrieval
Separate storage from delivery
Treat uploaded content as private by default. In the school example, a note moves from receiving to isolated quarantine, then to approved private storage only after checks succeed. The application stores a generated object identifier separately from the original display name. No upload is placed in a directory that executes server code.
Storage identifiers are not paths
Generate opaque storage identifiers on the server and map them to objects in an approved storage root. Never interpret a user filename as a storage location. Constrain filesystem operations to the intended root, reject unexpected links and collisions, and use platform-appropriate safe file APIs. A string prefix comparison is not sufficient proof of filesystem containment.
Example: retrieve only approved notes
Suppose note N1 is owned by student A in class C1. A may download N1 only when it is approved; student B cannot, even in C1. A teacher assigned to C1 may retrieve approved notes in that class under the fictional policy, but not notes in C2. Check identity, role, class, object and processing state on every request.
Delivery is another trust boundary
Use a controlled download handler or appropriately scoped, short-lived storage grants. A grant can remain usable until expiry depending on the storage system; design revocation accordingly. For downloads, choose the correct response media type, safe attachment disposition and browser protections. Active content may require a separate origin without application credentials. Random identifiers and hidden links do not replace authorization.
Practice: draw the boundary
Draw receiving → quarantine → processing → approved private storage → authorized download. Assign a narrow service identity to each stage. Predict the lab retrieval cases and explain what should happen when a note is deleted during a concurrent download; identify the consistency guarantees that a production design would need.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Upload storage and retrieval — knowledge check
Apply file security principles to fictional scenarios.
Which value should determine a storage location?
Student B requests approved note N1 owned by A. Same class. Decision?
May the owner retrieve a quarantined note?
Why use isolated storage outside executable directories?
What does a random identifier establish about authorization?