[lib][native] Sanitize media upload filenames
Summary:
Related: ENG-2562, ENG-2475
- Created a function that replaces all invalid characters in filename with underscores. If the filename is not present, it is randomly generated and extension is deduced from MIME type.
- Made the filename optional in MediaLibrarySelection type.
- Used the above function to make sure that filename is valid when processed in processMedia().
Test Plan:
On both platforms various different photos/videos including these containing spaces. Confirmed that all of them work and thumbnail generation doesn't crash.
Also manually tested the regex: https://regex101.com/r/1FCRbJ/2
Reviewers: ashoat, atul
Reviewed By: ashoat, atul
Subscribers: tomek
Differential Revision: https://phab.comm.dev/D6493