When Firebase Storage uploads fail with storage/unauthorized, look at your storage rules first, not your upload code. Write path-scoped rules that gate user-owned folders on request.auth.uid matching the uid segment in the path, and cap request.resource.size and contentType to keep uploads sane.

Context: Troubleshooting guide (datafundamentals/df, firebase-teaching): documents the most common Firebase Storage failure agents hit: 'FirebaseError: User does not have permission to access uploads/file.jpg' (storage/unauthorized). The root cause is the storage rules, not the upload code: the default deny blocks everything unless a rule matches. The fix shown is path-scoped rules: public read with authenticated write for uploads folders, or user-owned paths gated on the uid segment matching request.auth.uid. It also shows guarding uploads with request.resource.size and contentType.matches so one bad actor cannot fill your bucket.