You are currently viewing the new Anvil Editor Docs.
Switch to the Classic Editor Docs
You are currently viewing the Classic Editor Docs.
Switch to the new Anvil Editor Docs

anvil.google.drive Module

Classes

DriveItem


Instance Methods

delete()

Delete the DriveItem (this cannot be undone)

move(dest_folder)

Move the DriveItem from one folder to another

    trash()

    Move the DriveItem to the trash folder


    DriveItem Attributes

    id - string

    ID of the DriveItem


    File


    Base classes: anvil.google.drive.DriveItem, anvil.Media

    Instance Methods

    get_bytes()

    Get the contents of an object representing a Google Drive file. Native Google files such as Docs, Slides and Sheets must first be exported to an appropriate file type. All other file types support get_bytes().

    set_bytes(content)

    Set the contents of an object representing a Google Drive file.

      set_media(media)

      Upload new contents to an existing File. Media must be a Media object.


        Folder (more info)


        Base class: anvil.google.drive.DriveItem

        Instance Methods

        create_file(title, [content_bytes=None], [content_type='text/plain'])

        Create a new file within the Folder.

          create_folder(title)

          Create a new folder within the Folder.

            get(title) → anvil.google.drive.File instance

            Get the File item by title. The title argument should be a string.

              get_by_id(id) → anvil.google.drive.File instance

              Get the File item by ID. The ID argument should be a string.

                list_files() → generator(anvil.google.drive.File instance)

                List the files (not folders) in the Folder.

                list_folders() → generator(anvil.google.drive.Folder instance)

                List the folders (not files) in the Folder.


                Folder Attributes

                files - list(anvil.google.drive.File instance)

                List of File items in the Folder

                folders - list(anvil.google.drive.Folder instance)

                List of Folder items in the Folder


                Functions

                get_user_files() → anvil.google.drive.Folder instance (more info)

                Return the top-level folder containing all the files in the Users drive. anvil.google.drive.login() must be called first.


                login([extra_scopes=]) (more info)

                Prompt the user to log in to their Google account and ask permission to access their Google Drive files.



                  Do you still have questions?

                  Our Community Forum is full of helpful information and Anvil experts.


                  anvil.google.drive