Method to create a file on the Control-Server

    This method allows one to upload a file to the Control-Server. The file
    to be uploaded can be specified in two different ways either by specifying
    its content directly or or by specifying the file_path where the file is
    located.

    content can be in the form of: string, bytes or a file-descriptor.

def create(context, name, content=None, file_path=None, mime='text/plain',
           jobstate_id=None, md5=None, job_id=None, test_id=None):
    """Method to create a file on the Control-Server

    This method allows one to upload a file to the Control-Server. The file
    to be uploaded can be specified in two different ways either by specifying
    its content directly or or by specifying the file_path where the file is
    located.

    content can be in the form of: string, bytes or a file-descriptor.

    """

    if content and file_path:
        raise Exception('content and file_path are mutually exclusive')
    elif not content and not file_path:
        raise Exception(
            'At least one of content or file_path must be specified'
        )

    headers = {'DCI-NAME': name,
               'DCI-MIME': mime,
               'DCI-JOBSTATE-ID': jobstate_id,
               'DCI-MD5': md5,
               'DCI-JOB-ID': job_id,
               'DCI-TEST-ID': test_id}
    headers = utils.sanitize_kwargs(**headers)
    uri = '%s/%s' % (context.dci_cs_api, RESOURCE)

    if content:
        if not hasattr(content, 'read'):
            if not isinstance(content, bytes):
                content = content.encode('utf-8')
            content = io.BytesIO(content)
        return context.session.post(uri, headers=headers, data=content)
    else:
        if not os.path.exists(file_path):
            raise FileErrorException()
        with open(file_path, 'rb') as f:
            return context.session.post(uri, headers=headers, data=f)