added function get_file
This commit is contained in:
parent
b0f496c4d2
commit
57b72f82c0
1 changed files with 17 additions and 1 deletions
|
|
@ -211,4 +211,20 @@ def delete_file(fid, verbose=0):
|
|||
webnotes.conn.sql("delete from `tabFile Data` where name=%s", fid)
|
||||
path = os.path.join(webnotes.get_files_path(), fid.replace('/','-'))
|
||||
if os.path.exists(path):
|
||||
os.remove(path)
|
||||
os.remove(path)
|
||||
|
||||
def get_file(fname):
|
||||
f = get_file_system_name(fname)
|
||||
if f:
|
||||
file_id = f[0][0].replace('/','-')
|
||||
file_name = f[0][1]
|
||||
else:
|
||||
file_id = fname
|
||||
file_name = fname
|
||||
|
||||
# read the file
|
||||
import os
|
||||
with open(os.path.join(webnotes.get_files_path(), file_id), 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
return [file_name, content]
|
||||
Loading…
Add table
Reference in a new issue