def addResourceFile(self, pid, resource_file, resource_filename=None, progress_callback=None):
url = "<STR_LIT>".format(url_base=self.url_base,<EOL>pid=pid)<EOL>params = {}<EOL>close_fd = self._prepareFileForUpload(params, resource_file, resource_filename)<EOL>encoder = MultipartEncoder(params)<EOL>if progress_callback is None:<EOL><INDENT>progress_callback = default_progress_callback<EOL><DEDENT>monitor = MultipartEncoderMonitor(encoder, progress_callback)<EOL>r = self._request('<STR_LIT:POST>', url, data=monitor, headers={'<STR_LIT:Content-Type>': monitor.content_type})<EOL>if close_fd:<EOL><INDENT>fd = params['<STR_LIT:file>'][<NUM_LIT:1>]<EOL>fd.close()<EOL><DEDENT>if r.status_code != <NUM_LIT>:<EOL><INDENT>if r.status_code == <NUM_LIT>:<EOL><INDENT>raise HydroShareNotAuthorized(('<STR_LIT:POST>', url))<EOL><DEDENT>elif r.status_code == <NUM_LIT>:<EOL><INDENT>raise HydroShareNotFound((pid,))<EOL><DEDENT>else:<EOL><INDENT>raise HydroShareHTTPException((url, '<STR_LIT:POST>', r.status_code))<EOL><DEDENT><DEDENT>response = r.json()<EOL>return response<EOL>
Add a new file to an existing resource

        :param pid: The HydroShare ID of the resource
        :param resource_file: a read-only binary file-like object (i.e. opened with the flag 'rb') or a string
            representing path to file to be uploaded as part of the new resource
        :param resource_filename: string representing the filename of the resource file.  Must be specified
            if resource_file is a file-like object.  If resource_file is a string representing a valid file path,
            and resource_filename is not specified, resource_filename will be equal to os.path.basename(resource_file).
            is a string
        :param progress_callback: user-defined function to provide feedback to the user about the progress
            of the upload of resource_file.  For more information, see:
            http://toolbelt.readthedocs.org/en/latest/uploading-data.html#monitoring-your-streaming-multipart-upload

        :return: Dictionary containing 'resource_id' the ID of the resource to which the file was added, and
                'file_name' the filename of the file added.

        :raises: HydroShareNotAuthorized if user is not authorized to perform action.
        :raises: HydroShareNotFound if the resource was not found.
        :raises: HydroShareHTTPException if an unexpected HTTP response code is encountered.