private function _handleResourceUpload($value)
    {
      if (Cii::get($this->_result,'success', false) == true)
        {
            $meta = ContentMetadata::model()->findbyAttributes(array('content_id' => $this->_id, 'key' => $this->_result['filename']));

            if ($meta == NULL)
                $meta = new ContentMetadata;

            $meta->content_id = $this->_id;
            $meta->key = $this->_result['filename'];
            $meta->value = $value;
            if ($meta->save())
            {
                if ($this->_promote)
                    $this->_promote($this->_result['filename']);
                $this->_result['filepath'] = $value;
                return htmlspecialchars(CJSON::encode($this->_result), ENT_NOQUOTES);
            }
            else
                throw new CHttpException(400,  Yii::t('ciims.misc', 'Unable to save uploaded image.'));
        }
        else
            throw new CHttpException(400, $this->_result['error']);
    }