Interface DriveOperations
-
- All Known Implementing Classes:
DriveTemplate
public interface DriveOperationsDefines 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
- Author:
- Gabriel Axel
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description FileCommentaddComment(String fileId, FileComment comment)Adds a comment to a fileUserPermissionaddPermission(String fileId, UserPermission permission, boolean sendNotificationEmails)Adds a permission to a fileFilePropertyaddProperty(String fileId, FileProperty property)Adds a new property to a fileCommentReplyaddReply(String fileId, String commentId, CommentReply reply)Adds a reply to a file commentDriveFilecopy(String id)Create a copy of a fileDriveFilecopy(String id, String[] parentIds)Create a copy of a fileDriveFilecopy(String id, String[] parentIds, String title)Create a copy of a fileDriveFilecreateFileMetadata(DriveFile metadata)Creates an empty file with metadataDriveFilecreateFolder(String parentId, String name)Creates a foldervoiddelete(String id)Permanently deletes a fileorg.springframework.core.io.ResourcedownloadFile(String id)Downloads a file from Google Drive.org.springframework.core.io.ResourcedownloadFile(DriveFile file)Downloads a file from Google Drive.DriveFileQueryBuilderdriveFileQuery()Creates aDriveFileQueryBuilderFileCommentQueryBuilderfileCommentQueryBuilder(String fileId)Returns aFileCommentQueryBuilderfor listing the comments of a fileDriveAboutgetAbout()Get general Google Drive details for the current userDriveAppgetApp(String id)Returns an application by its IDList<DriveApp>getApps()Returns the applications authorized by the user to access Google Drive APIFileCommentsPagegetComments(String fileId, String pageToken)Returns the first default page of comments on a fileDriveFilegetFile(String id)Retrieves a file by its IDDriveFilesPagegetFiles(String parent, String pageToken)Returns the files and folders under a specified folderList<UserPermission>getPermissions(String fileId)Returns the permissions of a fileList<FileProperty>getProperties(String fileId)Get the custom properties applied to this fileFilePropertygetProperty(String fileId, String propertyKey)Get a specific custom property applied to this fileList<FileRevision>getRevisions(String fileId)Returns the revisions of a fileDriveFilesPagegetRootFiles(String pageToken)Returns files and folders under the root folderDriveFilesPagegetTrashedFiles(String pageToken)Returns trashed files and foldersDriveFilehide(String id)Hides a fileDriveFilemove(String id, String parentId)Move a file into a different foldervoidremoveComment(String fileId, String commentId)Removes a comment from a filevoidremovePermission(String fileId, String permissionId)Removes a permission from a filevoidremoveProperty(String fileId, String propertyKey)Deletes a propertyvoidremoveReply(String fileId, String commentId, String replyId)Removes a reply from a file commentDriveFilestar(String id)Stars a fileDriveFiletrash(String id)Moves a file to trashDriveFileunhide(String id)Unhides a fileDriveFileunstar(String id)Remove the star from a fileDriveFileuntrash(String id)Restores a file from trashFileCommentupdateComment(String fileId, String commentId, FileComment comment)Updates a comment to a fileFilePropertyupdateProperty(String fileId, FileProperty property)Updates a propertyCommentReplyupdateReply(String fileId, String commentId, String replyId, CommentReply reply)Updates a reply to a file commentFileRevisionupdateRevision(String fileId, String revisionId, FileRevision revision)Updates a file revisionUserPermissionupdatesPermission(String fileId, String permissionId, UserPermission permission)Updates a permission to a fileDriveFileupload(org.springframework.core.io.Resource resource, DriveFile metadata, UploadParameters parameters)Uploads a file using multipart
-
-
-
Method Detail
-
getAbout
DriveAbout getAbout()
Get general Google Drive details for the current user- Returns:
DriveAboutwith details for the current user
-
getApps
List<DriveApp> getApps()
Returns the applications authorized by the user to access Google Drive API- Returns:
- List of
DriveAppfor the current user
-
getApp
DriveApp getApp(String id)
Returns an application by its ID- Parameters:
id- The ID of the application- Returns:
DriveAppmatching the ID
-
getFile
DriveFile getFile(String id)
Retrieves a file by its ID- Parameters:
id- the ID to retrieve by- Returns:
DriveFilematching the ID
-
driveFileQuery
DriveFileQueryBuilder driveFileQuery()
Creates aDriveFileQueryBuilder- Returns:
- a new
DriveFileQueryBuilder
-
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
-
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
DriveFilecopy
-
copy
DriveFile copy(String id, String[] parentIds)
Create a copy of a file- Parameters:
id- The ID of the source fileparentIds- Array of parent folder ID to place the file into, or "root"- Returns:
- The newly-created
DriveFilecopy
-
copy
DriveFile copy(String id, String[] parentIds, String title)
Create a copy of a file- Parameters:
id- The ID of the source fileparentIds- 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
DriveFilecopy
-
move
DriveFile move(String id, String parentId)
Move a file into a different folder- Parameters:
id- The ID of the file to moveparentId- 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 contentmetadata- The file's metadataparameters- 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:
DriveFilerepresenting 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:
DriveFilerepresenting 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
UserPermissionfor the file
-
addPermission
UserPermission addPermission(String fileId, UserPermission permission, boolean sendNotificationEmails)
Adds a permission to a file- Parameters:
fileId- The file IDpermission-UserPermissionwith the permission settingssendNotificationEmails- Whether to send notification e-mails- Returns:
- The created
UserPermission
-
updatesPermission
UserPermission updatesPermission(String fileId, String permissionId, UserPermission permission)
Updates a permission to a file- Parameters:
fileId- The file IDpermissionId- the ID of the permissionpermission-UserPermissionwith new role and additionalRoles properties- Returns:
- The updated
UserPermission
-
removePermission
void removePermission(String fileId, String permissionId)
Removes a permission from a file- Parameters:
fileId- The file IDpermissionId- The ID of the permission
-
getRevisions
List<FileRevision> getRevisions(String fileId)
Returns the revisions of a file- Parameters:
fileId- The ID of the file- Returns:
- List of
FileRevision
-
updateRevision
FileRevision updateRevision(String fileId, String revisionId, FileRevision revision)
Updates a file revision- Parameters:
fileId- The ID of the filerevisionId- The ID of the revisionrevision-FileRevisionwith new pinned, publishAuto, published and publishedOutsideDomain properties- Returns:
- The updated
FileRevision
-
fileCommentQueryBuilder
FileCommentQueryBuilder fileCommentQueryBuilder(String fileId)
Returns aFileCommentQueryBuilderfor listing the comments of a file- Parameters:
fileId- The ID of the file- Returns:
FileCommentQueryBuilderfor the file
-
getComments
FileCommentsPage getComments(String fileId, String pageToken)
Returns the first default page of comments on a file- Parameters:
fileId- The ID of the filepageToken- 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 filecomment- 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 filecommentId- The ID of the commentcomment- 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 filecommentId- 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 filecommentId- The ID of the commentreply- 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 filecommentId- The ID of the commentreplyId- The ID of the replyreply- 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 filecommentId- The ID of the commentreplyId- 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 usesDriveFile.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 filepropertyKey- 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 fileproperty- Property representation- Returns:
- The new
FileProperty
-
updateProperty
FileProperty updateProperty(String fileId, FileProperty property)
Updates a property- Parameters:
fileId- The ID of the fileproperty- Property representation- Returns:
- The updated
FileProperty
-
-