HomePhabricator

Detect the MIME type of large files by examining the first chunk

Tags
None
Referenced Files
F1706837: Screen Shot 2016-06-30 at 1.32.37 PM.png
Jun 30 2016, 8:57 PM
Subscribers
None
Tokens
"Like" token, awarded by bjshively.

Description

Detect the MIME type of large files by examining the first chunk

Summary:
Fixes T11242. See that task for detailed discussion.

Previously, it didn't particularly matter that we don't MIME detect chunked files since they were all just big blobs of junk (PSDs, zips/tarballs, whatever) that we handled uniformly.

However, videos are large and the MIME type also matters.

  • Detect the overall mime type by detecitng the MIME type of the first chunk. This appears to work properly, at least for video.
  • Skip mime type detection on other chunks, which we were performing and ignoring. This makes uploading chunked files a little faster since we don't need to write stuff to disk.

Test Plan:
Uploaded a 50MB video locally, saw it as chunks with a "video/mp4" mime type, played it in the browser in Phabricator as an embedded HTML 5 video.

Screen Shot 2016-06-30 at 1.32.37 PM.png (1×1 px, 279 KB)

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11242

Differential Revision: https://secure.phabricator.com/D16204