
    ɧ-io                     P    d Z ddlmZmZ ddlmZ ddlZddlZ G d d          ZdS )z2
File Service
Handles file uploads and management
    )DictAny)PathNc                   @    e Zd Zd Zdeeef         fdZdedefdZ	dS )FileServicec                 f    t          d          | _        | j                            dd           d S )Nzuploads/logosT)parentsexist_ok)r   upload_pathmkdir)selfs    D/var/www/html/web-builder-api.evdpl.com/src/services/file_service.py__init__zFileService.__init__   s4    00td;;;;;    returnc                   K   	 d|j         v r |j                             d          d         nd}t          j                     d| }| j        |z  }|                                 d{V }t          j        |d          4 d{V }|                    |           d{V  ddd          d{V  n# 1 d{V swxY w Y   |d| t          |          dS # t          $ r$}t          dt          |                     d}~ww xY w)	zE
        Save uploaded logo file using async file operations
        .pngNwbz
asset/img/)filenamepathsizezLogo save failed: )r   splituuiduuid4r   readaiofilesopenwritelen	Exceptionstr)r   filefile_extensionunique_filename	file_pathcontentbufferes           r   	save_logozFileService.save_logo   s     	;=@DM=Q=QT]0055b99W\N!%@@@@O(?:I !IIKK''''''G  }Y55 , , , , , , ,ll7+++++++++, , , , , , , , , , , , , , , , , , , , , , , , , , , ,6_66G    	; 	; 	;9Q99:::	;s<   BC B4"C 4
B>>C B>C 
D	%DD	r   c                     | j         |z  S )z$
        Get logo file path
        )r   )r   r   s     r   get_logo_pathzFileService.get_logo_path*   s     (**r   N)
__name__
__module____qualname__r   r   r#   r   r+   r   r-    r   r   r   r      sh        < < <;tCH~ ; ; ; ;4+c +d + + + + + +r   r   )	__doc__typingr   r   pathlibr   r   r   r   r1   r   r   <module>r5      s    
                #+ #+ #+ #+ #+ #+ #+ #+ #+ #+r   