def download_local_file(filename, download_to_file):
<EOL>try:<EOL><INDENT>path = urllib2.urlparse.urlsplit(urllib.unquote(filename))[<NUM_LIT:2>]<EOL>if os.path.abspath(path) != path:<EOL><INDENT>msg = "<STR_LIT>"% (path, os.path.normpath(path))<EOL>raise InvenioFileCopyError(msg)<EOL><DEDENT>allowed_path_list = current_app.config.get(<EOL>'<STR_LIT>', []<EOL>)<EOL>allowed_path_list.append(current_app.config['<STR_LIT>'])<EOL>for allowed_path in allowed_path_list:<EOL><INDENT>if path.startswith(allowed_path):<EOL><INDENT>shutil.copy(path, download_to_file)<EOL>if os.path.getsize(download_to_file) == <NUM_LIT:0>:<EOL><INDENT>os.remove(download_to_file)<EOL>msg = "<STR_LIT>" % (filename,)<EOL>raise InvenioFileCopyError(msg)<EOL><DEDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>msg = "<STR_LIT>" % (path,)<EOL>raise InvenioFileCopyError()<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>msg = "<STR_LIT>" %(filename, download_to_file, str(e))<EOL>raise InvenioFileCopyError(msg)<EOL><DEDENT>return download_to_file<EOL>
Copies a local file to Invenio's temporary directory.

@param filename: the name of the file to copy
@type filename: string

@param download_to_file: the path to save the file to
@type download_to_file: string

@return: the path of the temporary file created
@rtype: string
@raise StandardError: if something went wrong