File Manager, show which user uploaded a file

Hello all.
A very quick and simple question. When I make a custom field in File, how do I make it show a fullname of who uploaded a file in File Manager?

Thank you.

Hi @ndmaar,

the person who has uploaded a file will be stored in the “owner” field in the database. This is accessible from JavaScript, Python and Jinja.

E.g. in Python/Jinja:

frappe.get_value("File", "name of file", "owner")

Note that the “name of file” is a hashed value like 070b7634e6. Getting an owner from a file by the file’s name, you might want to do something like this

file = frappe.get_list('File', filters={'file_name': 'your filename'}, fields=['name', 'owner'])
if file:
uploader = file[0]['owner']

That will be easier than adding a custom field. If you still want a field, add a field of type “Link” and enter “User” as option. Getting the default, you might want to check the frappe.user (JavaScript; in Python frappe.session.user)…

Hope this helps.

1 Like