music2storage/service.py
def upload(self, file_name):
        """
        Uploads the file associated with the file_name passed to Google Drive in the Music folder.

        :param str file_name: Filename of the file to be uploaded
        :return str: Original filename passed as an argument (in order for the worker to send it to the delete queue)
        """

        response = self.connection.files().list(q="name='Music' and mimeType='application/vnd.google-apps.folder' and trashed=false").execute()
        folder_id = response.get('files', [])[0]['id']
        file_metadata = {'name': file_name, 'parents': [folder_id]}
        media = MediaFileUpload(file_name, mimetype='audio/mpeg')
        
        log.info(f"Upload for {file_name} has started")
        start_time = time()
        self.connection.files().create(body=file_metadata, media_body=media, fields='id').execute()
        end_time = time()
        log.info(f"Upload for {file_name} has finished in {end_time - start_time} seconds")

        return file_name
def upload(self, file_name):
        response = self.connection.files().list(q="name='Music' and mimeType='application/vnd.google-apps.folder' and trashed=false").execute()
        folder_id = response.get('files', [])[0]['id']
        file_metadata = {'name': file_name, 'parents': [folder_id]}
        media = MediaFileUpload(file_name, mimetype='audio/mpeg')
        
        log.info(f"Upload for {file_name} has started")
        start_time = time()
        self.connection.files().create(body=file_metadata, media_body=media, fields='id').execute()
        end_time = time()
        log.info(f"Upload for {file_name} has finished in {end_time - start_time} seconds")

        return file_name
def upload ( self , file_name ) : response = self . connection . files ( ) . list ( q = "name='Music' and mimeType='application/vnd.google-apps.folder' and trashed=false" ) . execute ( ) folder_id = response . get ( 'files' , [ ] ) [ 0 ] [ 'id' ] file_metadata = { 'name' : file_name , 'parents' : [ folder_id ] } media = MediaFileUpload ( file_name , mimetype = 'audio/mpeg' ) log . info ( f"Upload for {file_name} has started" ) start_time = time ( ) self . connection . files ( ) . create ( body = file_metadata , media_body = media , fields = 'id' ) . execute ( ) end_time = time ( ) log . info ( f"Upload for {file_name} has finished in {end_time - start_time} seconds" ) return file_name
Uploads the file associated with the file_name passed to Google Drive in the Music folder.

        :param str file_name: Filename of the file to be uploaded
        :return str: Original filename passed as an argument (in order for the worker to send it to the delete queue)
Uploads the file associated with the file_name passed to Google Drive in the Music folder .