
    gx                     .    d dl Z d dlmZ d dlZd dlZd Zy)    N)Pathc                    d}|r-t         j                  j                  |j                        d   }n|j                  }d| z   dz   }t	        |      j                  dd       t        j                  ||      \  }}t        |d      5 }t        j                  ||       d d d        t        j                  |       |S # 1 sw Y    xY w)	NF   z./media//T)parentsexist_ok)suffixdirwb)ospathsplitextnamer   mkdirtempfilemkstempopenshutilcopyfileobjclose)	file_pathsourceextr	   fileDirectoryfdfilepathdests           ./var/www/html/brdwt/brdwt/utils/file_upload.pyhandle_uploaded_filer      s    
C
!!&++.q1*S0MdT:##6}ELB	h	 )64()HHRLO) )s   B>>C)r   pathlibr   r   r   r        r   <module>r#      s    	   r"   