Implemented uploading media from JS.

Implemented uploading media from JS.