platypush/plugins/google/drive/__init__.py
def upload(self,
               path: str,
               mime_type: Optional[str] = None,
               name: Optional[str] = None,
               description: Optional[str] = None,
               parents: Optional[List[str]] = None,
               starred: bool = False,
               target_mime_type: Optional[str] = None) -> GoogleDriveFile:
        """
        Upload a file to Google Drive.

        :param path: Path of the file to upload.
        :param mime_type: MIME type of the source file (e.g. "``image/jpeg``").
        :param name: Name of the target file. Default: same name as the source file.
        :param description: File description.
        :param parents: List of folder IDs that will contain the file (default: drive root).
        :param starred: If True, then the uploaded file will be marked as starred by the user.
        :param target_mime_type: Target MIME type. Useful if you want to e.g. import a CSV file as a Google Sheet
            (use "``application/vnd.google-apps.spreadsheet``), or an ODT file to a Google Doc
            (use "``application/vnd.google-apps.document``). See
            `the official documentation <https://developers.google.com/drive/api/v3/mime-types>`_ for a complete list
            of supported types.
        """
        # noinspection PyPackageRequirements
        from googleapiclient.http import MediaFileUpload

        path = os.path.abspath(os.path.expanduser(path))
        name = name or os.path.basename(path)
        metadata = {
            'name': name,
            'description': description,
            'parents': parents,
            'starred': starred,
        }

        if target_mime_type:
            metadata['mimeType'] = target_mime_type

        media = MediaFileUpload(path, mimetype=mime_type)
        service = self.get_service()
        file = service.files().create(
            body=metadata,
            media_body=media,
            fields='*'
        ).execute()

        return GoogleDriveFile(
            type=file.get('kind').split('#')[1],
            id=file.get('id'),
            name=file.get('name'),
            mime_type=file.get('mimeType'),
        )

        Upload a file to Google Drive.

        :param path: Path of the file to upload.
        :param mime_type: MIME type of the source file (e.g. "``image/jpeg``").
        :param name: Name of the target file. Default: same name as the source file.
        :param description: File description.
        :param parents: List of folder IDs that will contain the file (default: drive root).
        :param starred: If True, then the uploaded file will be marked as starred by the user.
        :param target_mime_type: Target MIME type. Useful if you want to e.g. import a CSV file as a Google Sheet
            (use "``application/vnd.google-apps.spreadsheet``), or an ODT file to a Google Doc
            (use "``application/vnd.google-apps.document``). See
            `the official documentation <https://developers.google.com/drive/api/v3/mime-types>`_ for a complete list
            of supported types.
        
Upload a file to Google Drive.
Upload a file to Google Drive .
def upload(self,
               path: str,
               mime_type: Optional[str] = None,
               name: Optional[str] = None,
               description: Optional[str] = None,
               parents: Optional[List[str]] = None,
               starred: bool = False,
               target_mime_type: Optional[str] = None) -> GoogleDriveFile:
        from googleapiclient.http import MediaFileUpload
        path = os.path.abspath(os.path.expanduser(path))
        name = name or os.path.basename(path)
        metadata = {
            'name': name,
            'description': description,
            'parents': parents,
            'starred': starred,
        }
        if target_mime_type:
            metadata['mimeType'] = target_mime_type
        media = MediaFileUpload(path, mimetype=mime_type)
        service = self.get_service()
        file = service.files().create(
            body=metadata,
            media_body=media,
            fields='*'
        ).execute()
        return GoogleDriveFile(
            type=file.get('kind').split('#')[1],
            id=file.get('id'),
            name=file.get('name'),
            mime_type=file.get('mimeType'),
        )
def upload ( self , path : str , mime_type : Optional [ str ] = None , name : Optional [ str ] = None , description : Optional [ str ] = None , parents : Optional [ List [ str ] ] = None , starred : bool = False , target_mime_type : Optional [ str ] = None ) -> GoogleDriveFile : from googleapiclient . http import MediaFileUpload path = os . path . abspath ( os . path . expanduser ( path ) ) name = name or os . path . basename ( path ) metadata = { 'name' : name , 'description' : description , 'parents' : parents , 'starred' : starred , } if target_mime_type : metadata [ 'mimeType' ] = target_mime_type media = MediaFileUpload ( path , mimetype = mime_type ) service = self . get_service ( ) file = service . files ( ) . create ( body = metadata , media_body = media , fields = '*' ) . execute ( ) return GoogleDriveFile ( type = file . get ( 'kind' ) . split ( '#' ) [ 1 ] , id = file . get ( 'id' ) , name = file . get ( 'name' ) , mime_type = file . get ( 'mimeType' ) , )
Upload a file to Google Drive.
Upload a file to Google Drive .
"""
        Upload a file to Google Drive.

        :param path: Path of the file to upload.
        :param mime_type: MIME type of the source file (e.g. "``image/jpeg``").
        :param name: Name of the target file. Default: same name as the source file.
        :param description: File description.
        :param parents: List of folder IDs that will contain the file (default: drive root).
        :param starred: If True, then the uploaded file will be marked as starred by the user.
        :param target_mime_type: Target MIME type. Useful if you want to e.g. import a CSV file as a Google Sheet
            (use "``application/vnd.google-apps.spreadsheet``), or an ODT file to a Google Doc
            (use "``application/vnd.google-apps.document``). See
            `the official documentation <https://developers.google.com/drive/api/v3/mime-types>`_ for a complete list
            of supported types.
        """ # noinspection PyPackageRequirements
self
path
str
Path of the file to upload.
Path of the file to upload .
mime_type
Optional[str]
MIME type of the source file .
MIME type of the source file .
name
Optional[str]
Name of the target file. Default: same name as the source file.
Name of the target file . Default : same name as the source file .
description
Optional[str]
None
parents
Optional[List[str]]
List of folder IDs that will contain the file (default: drive root).
List of folder IDs that will contain the file ( default : drive root ) .
starred
bool
If True, then the uploaded file will be marked as starred by the user.
If True then the uploaded file will be marked as starred by the user .
target_mime_type
Optional[str]
Target MIME type. Useful if you want to e.g. import a CSV file as a Google Sheet
(use "``application/vnd.google-apps.spreadsheet``), or an ODT file to a Google Doc
(use "``application/vnd.google-apps.document``). See
`the official documentation `_ for a complete list
of supported types.
Target MIME type . Useful if you want to e . g . import a CSV file as a Google Sheet ( use " ` ` application / vnd . google - apps . spreadsheet ` ` ) or an ODT file to a Google Doc ( use " ` ` application / vnd . google - apps . document ` ` ) . See ` the official documentation ` _ for a complete list of supported types .