All Downloads are FREE. Search and download functionalities are using the official Maven repository.

target.apidocs.com.google.api.services.drive.Drive.Files.html Maven / Gradle / Ivy

There is a newer version: v3-rev20241206-2.0.0
Show newest version






Drive.Files (Google Drive API v3-rev20241027-2.0.0)












com.google.api.services.drive

Class Drive.Files

  • Enclosing class:
    Drive


    public class Drive.Files
    extends Object
    The "files" collection of methods.
    • Constructor Detail

      • Files

        public Files()
    • Method Detail

      • copy

        public Drive.Files.Copy copy(String fileId,
                                     File content)
                              throws IOException
        Creates a copy of a file and applies any requested updates with patch semantics. Create a request for the method "files.copy". This request holds the parameters needed by the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.
        Parameters:
        fileId - The ID of the file.
        content - the File
        Returns:
        the request
        Throws:
        IOException
      • create

        public Drive.Files.Create create(File content)
                                  throws IOException
        Creates a new file. This method supports an upload* URI and accepts uploaded media with the following characteristics: - *Maximum file size:* 5,120 GB - *Accepted Media MIME types:*`*` Note: Specify a valid MIME type, rather than the literal `*` value. The literal `*` is only used to indicate that any valid MIME type can be uploaded. For more information on uploading files, see [Upload file data](/drive/api/guides/manage-uploads). Apps creating shortcuts with `files.create` must specify the MIME type `application/vnd.google-apps.shortcut`. Apps should specify a file extension in the `name` property when inserting files with the API. For example, an operation to insert a JPEG file should specify something like `"name": "cat.jpg"` in the metadata. Subsequent `GET` requests include the read-only `fileExtension` property populated with the extension originally specified in the `title` property. When a Google Drive user requests to download a file, or when the file is downloaded through the sync client, Drive builds a full filename (with extension) based on the title. In cases where the extension is missing, Drive attempts to determine the extension based on the file's MIME type. Create a request for the method "files.create". This request holds the parameters needed by the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.
        Parameters:
        content - the File
        Returns:
        the request
        Throws:
        IOException
      • create

        public Drive.Files.Create create(File content,
                                         com.google.api.client.http.AbstractInputStreamContent mediaContent)
                                  throws IOException
        Creates a new file. This method supports an upload* URI and accepts uploaded media with the following characteristics: - *Maximum file size:* 5,120 GB - *Accepted Media MIME types:*`*` Note: Specify a valid MIME type, rather than the literal `*` value. The literal `*` is only used to indicate that any valid MIME type can be uploaded. For more information on uploading files, see [Upload file data](/drive/api/guides/manage-uploads). Apps creating shortcuts with `files.create` must specify the MIME type `application/vnd.google-apps.shortcut`. Apps should specify a file extension in the `name` property when inserting files with the API. For example, an operation to insert a JPEG file should specify something like `"name": "cat.jpg"` in the metadata. Subsequent `GET` requests include the read-only `fileExtension` property populated with the extension originally specified in the `title` property. When a Google Drive user requests to download a file, or when the file is downloaded through the sync client, Drive builds a full filename (with extension) based on the title. In cases where the extension is missing, Drive attempts to determine the extension based on the file's MIME type. Create a request for the method "files.create". This request holds the parameters needed by the the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.

        This method should be used for uploading media content.

        Parameters:
        content - the File media metadata or null if none
        mediaContent - The media HTTP content.
        Returns:
        the request
        Throws:
        IOException - if the initialization of the request fails
      • delete

        public Drive.Files.Delete delete(String fileId)
                                  throws IOException
        Permanently deletes a file owned by the user without moving it to the trash. If the file belongs to a shared drive, the user must be an `organizer` on the parent folder. If the target is a folder, all descendants owned by the user are also deleted. Create a request for the method "files.delete". This request holds the parameters needed by the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.
        Parameters:
        fileId - The ID of the file.
        Returns:
        the request
        Throws:
        IOException
      • download

        public Drive.Files.Download download(String fileId)
                                      throws IOException
        Downloads content of a file. Operations are valid for 24 hours from the time of creation. Create a request for the method "files.download". This request holds the parameters needed by the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.
        Parameters:
        fileId - Required. The ID of the file to download.
        Returns:
        the request
        Throws:
        IOException
      • emptyTrash

        public Drive.Files.EmptyTrash emptyTrash()
                                          throws IOException
        Permanently deletes all of the user's trashed files. Create a request for the method "files.emptyTrash". This request holds the parameters needed by the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.
        Returns:
        the request
        Throws:
        IOException
      • export

        public Drive.Files.Export export(String fileId,
                                         String mimeType)
                                  throws IOException
        Exports a Google Workspace document to the requested MIME type and returns exported byte content. Note that the exported content is limited to 10MB. Create a request for the method "files.export". This request holds the parameters needed by the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.
        Parameters:
        fileId - The ID of the file.
        mimeType - Required. The MIME type of the format requested for this export.
        Returns:
        the request
        Throws:
        IOException
      • generateIds

        public Drive.Files.GenerateIds generateIds()
                                            throws IOException
        Generates a set of file IDs which can be provided in create or copy requests. Create a request for the method "files.generateIds". This request holds the parameters needed by the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.
        Returns:
        the request
        Throws:
        IOException
      • get

        public Drive.Files.Get get(String fileId)
                            throws IOException
        Gets a file's metadata or content by ID. If you provide the URL parameter `alt=media`, then the response includes the file contents in the response body. Downloading content with `alt=media` only works if the file is stored in Drive. To download Google Docs, Sheets, and Slides use [`files.export`](/drive/api/reference/rest/v3/files/export) instead. For more information, see [Download & export files](/drive/api/guides/manage-downloads). Create a request for the method "files.get". This request holds the parameters needed by the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.
        Parameters:
        fileId - The ID of the file.
        Returns:
        the request
        Throws:
        IOException
      • list

        public Drive.Files.List list()
                              throws IOException
        Lists the user's files. This method accepts the `q` parameter, which is a search query combining one or more search terms. For more information, see the [Search for files & folders](/drive/api/guides/search-files) guide. *Note:* This method returns *all* files by default, including trashed files. If you don't want trashed files to appear in the list, use the `trashed=false` query parameter to remove trashed files from the results. Create a request for the method "files.list". This request holds the parameters needed by the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.
        Returns:
        the request
        Throws:
        IOException
      • listLabels

        public Drive.Files.ListLabels listLabels(String fileId)
                                          throws IOException
        Lists the labels on a file. Create a request for the method "files.listLabels". This request holds the parameters needed by the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.
        Parameters:
        fileId - The ID for the file.
        Returns:
        the request
        Throws:
        IOException
      • modifyLabels

        public Drive.Files.ModifyLabels modifyLabels(String fileId,
                                                     ModifyLabelsRequest content)
                                              throws IOException
        Modifies the set of labels applied to a file. Returns a list of the labels that were added or modified. Create a request for the method "files.modifyLabels". This request holds the parameters needed by the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.
        Parameters:
        fileId - The ID of the file to which the labels belong.
        content - the ModifyLabelsRequest
        Returns:
        the request
        Throws:
        IOException
      • update

        public Drive.Files.Update update(String fileId,
                                         File content)
                                  throws IOException
        Updates a file's metadata and/or content. When calling this method, only populate fields in the request that you want to modify. When updating fields, some fields might be changed automatically, such as `modifiedDate`. This method supports patch semantics. This method supports an upload* URI and accepts uploaded media with the following characteristics: - *Maximum file size:* 5,120 GB - *Accepted Media MIME types:*`*` Note: Specify a valid MIME type, rather than the literal `*` value. The literal `*` is only used to indicate that any valid MIME type can be uploaded. For more information on uploading files, see [Upload file data](/drive/api/guides/manage-uploads). Create a request for the method "files.update". This request holds the parameters needed by the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.
        Parameters:
        fileId - The ID of the file.
        content - the File
        Returns:
        the request
        Throws:
        IOException
      • update

        public Drive.Files.Update update(String fileId,
                                         File content,
                                         com.google.api.client.http.AbstractInputStreamContent mediaContent)
                                  throws IOException
        Updates a file's metadata and/or content. When calling this method, only populate fields in the request that you want to modify. When updating fields, some fields might be changed automatically, such as `modifiedDate`. This method supports patch semantics. This method supports an upload* URI and accepts uploaded media with the following characteristics: - *Maximum file size:* 5,120 GB - *Accepted Media MIME types:*`*` Note: Specify a valid MIME type, rather than the literal `*` value. The literal `*` is only used to indicate that any valid MIME type can be uploaded. For more information on uploading files, see [Upload file data](/drive/api/guides/manage-uploads). Create a request for the method "files.update". This request holds the parameters needed by the the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.

        This method should be used for uploading media content.

        Parameters:
        fileId - The ID of the file.
        content - the File media metadata or null if none
        mediaContent - The media HTTP content.
        Returns:
        the request
        Throws:
        IOException - if the initialization of the request fails
      • watch

        public Drive.Files.Watch watch(String fileId,
                                       Channel content)
                                throws IOException
        Subscribes to changes to a file. Create a request for the method "files.watch". This request holds the parameters needed by the drive server. After setting any optional parameters, call the AbstractGoogleClientRequest.execute() method to invoke the remote operation.
        Parameters:
        fileId - The ID of the file.
        content - the Channel
        Returns:
        the request
        Throws:
        IOException
      • accessproposals

        public Drive.Files.Accessproposals accessproposals()
        An accessor for creating requests from the Accessproposals collection.

        The typical use is:

            Drive drive = new Drive(...);
            Drive.Accessproposals.List request = drive.accessproposals().list(parameters ...)
         
        Returns:
        the resource collection

Copyright © 2011–2024 Google. All rights reserved.





© 2015 - 2024 Weber Informatics LLC | Privacy Policy