Context : Implement prod Django
web project in Centos env.
I am trying to solve a function on file storage action that didn't work but i cant see why?... maybe a permission problem...
I have a pretty same function that work...
The function
import os
def manager_file_tasks(file, archive_path):
print(file, archive_path)
# i got this : file.csv /MYHOME/Site_Django/media/archive_file/uploadedFiles
tmp_archive_path = os.path.join(BASE_DIR, 'visualisation', 'UploadFiles', 'file')
# Test if the folder archive exist
if not os.path.exists(tmp_archive_path):
os.makedirs(tmp_archive_path)
print(tmp_archive_path)
# i got this : /MYHOME/Site_Django/visualisation/UploadFiles/file
fs = FileSystemStorage(location=tmp_archive_path)
print(fs)
# i got this : <django.core.files.storage.FileSystemStorage object at 0x7f57f622bda0>
print(armdb_file.name, armdb_file)
# i got this : file.csv file.csv
print(fs.save(armdb_file.name, armdb_file))
# NO RESULT .... :(
filename = fs.save(armdb_file.name, armdb_file)
print(filename)
armdb_file = fs.path(filename)
print(armdb_file)
# some other stuffs are made after....
Here the rights of the folder:
[me@web01]$ ll /MYHOME/Site_Django/visualisation/UploadFiles/
total 0
drw-r--r--. 2 apache apache 6 10 oct. 11:22 file
EDIT 1
I think that i resolve a part of the problem (that encounter with SELinux)
with this command line :
sudo chcon -t httpd_sys_content_t /MYHOME/Site_Django -R
EDIT 2
The file dont exist in my tmp folder :/ Even the python code :
print(file.file.name)
return
/tmp/tmp1t_ahpg4.upload.csv
I cant read this file with that :
with open(file,"r") as f:
print(f.read())
Thanks in advance for the help.