Interface DriveOperations

  • All Known Implementing Classes:
    DriveTemplate

    public interface DriveOperations
    Defines operations for integrating with Google Drive. Requires OAuth scope(s) from the following:
    • https://www.googleapis.com/auth/drive.file
    • https://www.googleapis.com/auth/drive
    • https://www.googleapis.com/auth/drive.apps.readonly
    • https://www.googleapis.com/auth/drive.readonly
    • https://www.googleapis.com/auth/drive.readonly.metadata
    See https://developers.google .com/drive/scopes for details about the different scopes
    Author:
    Gabriel Axel
    • Method Detail

      • getAbout

        DriveAbout getAbout()
        Get general Google Drive details for the current user
        Returns:
        DriveAbout with details for the current user
      • getApps

        List<DriveApp> getApps()
        Returns the applications authorized by the user to access Google Drive API
        Returns:
        List of DriveApp for the current user
      • getApp

        DriveApp getApp​(String id)
        Returns an application by its ID
        Parameters:
        id - The ID of the application
        Returns:
        DriveApp matching the ID
      • getFile

        DriveFile getFile​(String id)
        Retrieves a file by its ID
        Parameters:
        id - the ID to retrieve by
        Returns:
        DriveFile matching the ID
      • getRootFiles

        DriveFilesPage getRootFiles​(String pageToken)
        Returns files and folders under the root folder
        Parameters:
        pageToken - Page token or null
        Returns:
        DriveFilesPage
      • getFiles

        DriveFilesPage getFiles​(String parent,
                                String pageToken)
        Returns the files and folders under a specified folder
        Parameters:
        parent - folder ID or "root"
        pageToken - Page token or null
        Returns:
        DriveFilesPage
      • getTrashedFiles

        DriveFilesPage getTrashedFiles​(String pageToken)
        Returns trashed files and folders
        Parameters:
        pageToken - Page token or null
        Returns:
        DriveFilesPage
      • trash

        DriveFile trash​(String id)
        Moves a file to trash
        Parameters:
        id - The ID of the file to trash
        Returns:
        The updated DriveFile
      • untrash

        DriveFile untrash​(String id)
        Restores a file from trash
        Parameters:
        id - The ID of the file to untrash return The updated DriveFile
        Returns:
        The trashed DriveFile
      • star

        DriveFile star​(String id)
        Stars a file
        Parameters:
        id - The ID of the file to star
        Returns:
        The updated DriveFile
      • unstar

        DriveFile unstar​(String id)
        Remove the star from a file
        Parameters:
        id - The ID of the file to unstar
        Returns:
        The updated DriveFile
      • hide

        DriveFile hide​(String id)
        Hides a file
        Parameters:
        id - The ID of the file to hide
        Returns:
        The updated DriveFile
      • unhide

        DriveFile unhide​(String id)
        Unhides a file
        Parameters:
        id - The ID of the file to unhide
        Returns:
        The updated DriveFile
      • delete

        void delete​(String id)
        Permanently deletes a file
        Parameters:
        id - The ID of the file to delete
      • copy

        DriveFile copy​(String id)
        Create a copy of a file
        Parameters:
        id - The ID of the source file
        Returns:
        The newly-created DriveFile copy
      • copy

        DriveFile copy​(String id,
                       String[] parentIds)
        Create a copy of a file
        Parameters:
        id - The ID of the source file
        parentIds - Array of parent folder ID to place the file into, or "root"
        Returns:
        The newly-created DriveFile copy
      • copy

        DriveFile copy​(String id,
                       String[] parentIds,
                       String title)
        Create a copy of a file
        Parameters:
        id - The ID of the source file
        parentIds - Array of parent folder ID to place the file into, or "root"
        title - The title to apply to the new file
        Returns:
        The newly-created DriveFile copy
      • move

        DriveFile move​(String id,
                       String parentId)
        Move a file into a different folder
        Parameters:
        id - The ID of the file to move
        parentId - The parent folder ID to move the file to, or "root"
        Returns:
        The updated DriveFile
      • upload

        DriveFile upload​(org.springframework.core.io.Resource resource,
                         DriveFile metadata,
                         UploadParameters parameters)
        Uploads a file using multipart
        Parameters:
        resource - Reference to the file's content
        metadata - The file's metadata
        parameters - Parameters for uploading and processing the file
        Returns:
        The file resource that was created
      • createFileMetadata

        DriveFile createFileMetadata​(DriveFile metadata)
        Creates an empty file with metadata
        Parameters:
        metadata - The file's properties
        Returns:
        DriveFile representing the created file
      • createFolder

        DriveFile createFolder​(String parentId,
                               String name)
        Creates a folder
        Parameters:
        parentId - The parent folder ID or "root"
        name - The name of the folder to create
        Returns:
        DriveFile representing the created folder
      • getPermissions

        List<UserPermission> getPermissions​(String fileId)
        Returns the permissions of a file
        Parameters:
        fileId - The ID of the file
        Returns:
        List of UserPermission for the file
      • addPermission

        UserPermission addPermission​(String fileId,
                                     UserPermission permission,
                                     boolean sendNotificationEmails)
        Adds a permission to a file
        Parameters:
        fileId - The file ID
        permission - UserPermission with the permission settings
        sendNotificationEmails - Whether to send notification e-mails
        Returns:
        The created UserPermission
      • removePermission

        void removePermission​(String fileId,
                              String permissionId)
        Removes a permission from a file
        Parameters:
        fileId - The file ID
        permissionId - The ID of the permission
      • updateRevision

        FileRevision updateRevision​(String fileId,
                                    String revisionId,
                                    FileRevision revision)
        Updates a file revision
        Parameters:
        fileId - The ID of the file
        revisionId - The ID of the revision
        revision - FileRevision with new pinned, publishAuto, published and publishedOutsideDomain properties
        Returns:
        The updated FileRevision
      • getComments

        FileCommentsPage getComments​(String fileId,
                                     String pageToken)
        Returns the first default page of comments on a file
        Parameters:
        fileId - The ID of the file
        pageToken - Page token or null
        Returns:
        Page of comments
      • addComment

        FileComment addComment​(String fileId,
                               FileComment comment)
        Adds a comment to a file
        Parameters:
        fileId - The ID of the file
        comment - The new comment
        Returns:
        The created FileComment
      • updateComment

        FileComment updateComment​(String fileId,
                                  String commentId,
                                  FileComment comment)
        Updates a comment to a file
        Parameters:
        fileId - The ID of the file
        commentId - The ID of the comment
        comment - Comment with the new content
        Returns:
        The updated FileComment
      • removeComment

        void removeComment​(String fileId,
                           String commentId)
        Removes a comment from a file
        Parameters:
        fileId - The ID of the file
        commentId - The ID of the comment
      • addReply

        CommentReply addReply​(String fileId,
                              String commentId,
                              CommentReply reply)
        Adds a reply to a file comment
        Parameters:
        fileId - The ID of the file
        commentId - The ID of the comment
        reply - The new reply
        Returns:
        The created CommentReply
      • updateReply

        CommentReply updateReply​(String fileId,
                                 String commentId,
                                 String replyId,
                                 CommentReply reply)
        Updates a reply to a file comment
        Parameters:
        fileId - The ID of the file
        commentId - The ID of the comment
        replyId - The ID of the reply
        reply - Reply with new content
        Returns:
        The updated CommentReply
      • removeReply

        void removeReply​(String fileId,
                         String commentId,
                         String replyId)
        Removes a reply from a file comment
        Parameters:
        fileId - The ID of the file
        commentId - The ID of the comment
        replyId - The ID of the reply
      • downloadFile

        org.springframework.core.io.Resource downloadFile​(String id)
        Downloads a file from Google Drive. This method first sends a request to get the download URL, and then another request to download the file.
        Parameters:
        id - The file ID
        Returns:
        Resource abstraction for the file
      • downloadFile

        org.springframework.core.io.Resource downloadFile​(DriveFile file)
        Downloads a file from Google Drive. This method uses DriveFile.getDownloadUrl(), which may have expired since the file metadata was fetched.
        Parameters:
        file - The file metadata
        Returns:
        Resource abstraction for the file
      • getProperties

        List<FileProperty> getProperties​(String fileId)
        Get the custom properties applied to this file
        Parameters:
        fileId - The ID of the file
        Returns:
        The list of properties defined
      • getProperty

        FileProperty getProperty​(String fileId,
                                 String propertyKey)
        Get a specific custom property applied to this file
        Parameters:
        fileId - The ID of the file
        propertyKey - The key of the property
        Returns:
        The the property information
      • addProperty

        FileProperty addProperty​(String fileId,
                                 FileProperty property)
        Adds a new property to a file
        Parameters:
        fileId - The ID of the file
        property - Property representation
        Returns:
        The new FileProperty
      • updateProperty

        FileProperty updateProperty​(String fileId,
                                    FileProperty property)
        Updates a property
        Parameters:
        fileId - The ID of the file
        property - Property representation
        Returns:
        The updated FileProperty
      • removeProperty

        void removeProperty​(String fileId,
                            String propertyKey)
        Deletes a property
        Parameters:
        fileId - The ID of the file
        propertyKey - The key of the property