How to find the origin of a file upload from within wp_handle_upload?

I was able to figure it out by looking at the form parameters, which I don’t really like doing since it’s not part of the wordpress api. if anybody has a better idea, please leave a comment.

$_REQUEST['post_id'] > 0 // it's being uploaded from a page/post
$_REQUEST['post_id'] == 0 // it's being uploaded from the media library
empty($_REQUEST['post_id']) // it came from somewhere else (plugin, theme, etc)

It seems to be reliable for posts and library, but the “other” is probably not 100% reliable since plugins and themes could add parameters to trick the code into thinking it was one of the other types.