When I upload a file into Django server,the file permission seems to be like
-rw-r--r-- 1 bangtest nobody 5198 May 2 00:37 image.jpg
But I want to upload these files as root user,how can I do that using python in Django application.
I have tried using this
import pwd
import grp
import os
uid = pwd.getpwnam("root").pw_uid
gid = grp.getgrnam("root").gr_gid
path = '/home/bangtest/alpha/media/products/image_2081.jpg'
os.chown(path, uid, gid)
Then I am getting error like
OSError: [Errno 1] Operation not permitted: '/home/bangtest/alpha/media/products/image_2081.jpg'
Suggest me a solution for this issue.
Thanks