def getResourceFile(self, pid, filename, destination=None):
url = "<STR_LIT>".format(url_base=self.url_base,<EOL>pid=pid,<EOL>filename=filename)<EOL>if destination:<EOL><INDENT>if not os.path.isdir(destination):<EOL><INDENT>raise HydroShareArgumentException("<STR_LIT>".format(destination))<EOL><DEDENT>if not os.access(destination, os.W_OK):<EOL><INDENT>raise HydroShareArgumentException("<STR_LIT>".format(destination))<EOL><DEDENT><DEDENT>r = self._request('<STR_LIT:GET>', url, stream=True)<EOL>if r.status_code != <NUM_LIT:200>:<EOL><INDENT>if r.status_code == <NUM_LIT>:<EOL><INDENT>raise HydroShareNotAuthorized(('<STR_LIT:GET>', url))<EOL><DEDENT>elif r.status_code == <NUM_LIT>:<EOL><INDENT>raise HydroShareNotFound((pid, filename))<EOL><DEDENT>else:<EOL><INDENT>raise HydroShareHTTPException((url, '<STR_LIT:GET>', r.status_code))<EOL><DEDENT><DEDENT>if destination is None:<EOL><INDENT>return r.iter_content(STREAM_CHUNK_SIZE)<EOL><DEDENT>else:<EOL><INDENT>filepath = os.path.join(destination, filename)<EOL>with open(filepath, '<STR_LIT:wb>') as fd:<EOL><INDENT>for chunk in r.iter_content(STREAM_CHUNK_SIZE):<EOL><INDENT>fd.write(chunk)<EOL><DEDENT><DEDENT>return filepath<EOL><DEDENT>
Get a file within a resource.

        :param pid: The HydroShare ID of the resource
        :param filename: String representing the name of the resource file to get.
        :param destination: String representing the directory to save the resource file to. If None, a stream
            to the resource file will be returned instead.
        :return: The path of the downloaded file (if destination was specified), or a stream to the resource
            file.

        :raises: HydroShareArgumentException if any parameters are invalid.
        :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.