We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All

Documents from this version have been archived, and will not continue to be maintained. Please use the latest version.

HMS Core ReferencesDrive KitClient APIservices.drive Drive.FilesDrive.Files.Copy

Drive.Files.Copy

class info
public class Drive.Files.Copy extends DriveRequest<File>
Drive.Files.Copy class.

Protected Constructor Summary

Constructor name

Drive.Files.Copy(String fileId, File content) 

Constructor for the Drive.Files.Copy class.

Public Method Summary

Return typeMethod name
Drive.Files.Copy

setFields(String fields)

Sets the fields to be contained in a response.

Drive.Files.Copy

set(String parameterName, Object value)

Sets the given parameter value for the given parameter name.

String

getFileId()

Obtains a file ID.

Drive.Files.Copy

setFileId(String fileId)

Sets a file ID.

File

execute()

Sends an HTTP request and returns the object to be converted.

Drive.Files.Copy

setForm(String form)

Sets the response data format.

Drive.Files.Copy

setPrettyPrint(Boolean prettyPrint)

Sets whether to return a response containing indentations and line-wrapping breaks.

Drive.Files.Copy

setQuotaId(String quotaId)

Sets a string of less than 40 characters to identify a user. The string is used by the server to restrict the user's API calls.

Protected Constructors

constructor
protected Drive.Files.Copy (String fileId, File content)
Constructs an object of the Drive.Files.Copy class.

Parameters

Parameter nameParameter desc
fileIdFile ID.
contentFile to be copied.

Public Methods

Method
public Drive.Files.Copy setFields(String fields)
Sets the fields to be contained in a response.

Parameters

Parameter nameParameter desc
fieldsFields to be contained in a response. An asterisk (*) can be used to match all related fields.

Return

typedesc
Drive.Files.CopyA Drive.Files.Copy object.
Method


public Drive.Files.Copy set(String parameterName, Object value)

Sets the given parameter value for the given parameter name.

Parameters

Parameter nameParameter desc
parameterNameParameter name.
valueParameter value.

Return

typedesc
Drive.Files.CopyA Drive.Files.Copy object.
Method


public String getFileId()

Obtains a file ID.

Return

typedesc
StringFile ID.
Method


public Drive.Files.Copy setFileId(String fileId)

Sets a file ID.

Parameters

Parameter nameParameter desc
fileIdFile ID.

Return

typedesc
Drive.Files.CopyA Drive.Files.Copy object.
Method


public Drive.Files.Copy setForm(String form)

Sets the response data format.

Parameters

Parameter nameParameter desc
formResponse data format. The default data format is JSON, and only this format is supported currently.

Return

typedesc
Drive.Files.CopyA Drive.Files.Copy object.
Method


public Drive.Files.Copy setPrettyPrint(Boolean prettyPrint)

Sets whether to return a response containing indentations and line-wrapping breaks.

Parameters

Parameter nameParameter desc
prettyPrintIndicates whether to return a response containing indentations and line-wrapping breaks. The value is of the Boolean type.

Return

typedesc
Drive.Files.CopyA Drive.Files.Copy object.
Method


public Drive.Files.Copy setQuotaId(String quotaId)

Sets a string of fewer than 40 characters to identify a user. The string is used by the server to restrict the user’s API calls.

Parameters

Parameter nameParameter desc
quotaIdSets a string of less than 40 characters to identify a user. The string is used by the server to restrict the user's API calls.

Return

typedesc
Drive.Files.CopyA Drive.Files.Copy object.
Method


public T execute() throws IOException

Sends an HTTP request and returns the object to be converted.

Throws

Parameter nameParameter desc
java.io.IOException

I/O exception thrown upon an API call failure. You can use the getMessage() method to obtain the error description.

Return

typedesc
FileThe Drive.Files.Copy class extends DriveRequest<File>. Therefore, the return result of the execute() method is encapsulated as a DriveRequest<File> object.


Sample Code

Collapse
Word wrap
Dark theme
Copy code
  1. private void copyFile(Drive drive, File file) {
  2.    try {
  3.        File copyFile = new File().setName(file.getName + "_copy");
  4.        Drive.Files.Copy copyObject = drive.files().copy(file.getId(), copyFile);
  5.        File mfile = copyObject.execute();
  6.    } catch (Exception e) {
  7.        Log.e(TAG, "copyFile error: " + e.toString());
  8.    }
  9. }

This page may contain third-party content. For details, click here.
Search in References
Enter a keyword.