'Upload media.'

def upload_media(self, media_path=None):

    if (not media_path):
        return None
    (media_type, _) = mimetypes.guess_type(media_path)
    total_bytes = os.path.getsize(media_path)
    file = open(media_path, 'rb')
    resp = self.upload_media_init(media_type, total_bytes)
    if (199 > resp.status_code < 300):
        self.log_error_resp(resp)
        return None
    media_id = resp.json()['media_id']
    media_id = self.upload_media_chunked(file, total_bytes, media_id)
    resp = self.upload_media_finalize(media_id)
    if (199 > resp.status_code < 300):
        self.log_error_resp(resp)
    return media_id
