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
MaterialsConsole

Drive.Files.Get

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

Protected Constructor Summary

Constructor name

Drive.Files.Get(String fileId) 

Constructor for the Drive.Files.Get class.

Public Method Summary

Return typeMethod name
Drive.Files.Get

setFields(String fields)

Sets the fields to be contained in a response.

Drive.Files.Get

set(String parameterName, Object value)

Sets the given parameter value for the given parameter name.

String

getFileId()

Obtains a file ID.

Drive.Files.Get

setFileId(String fileId)

Sets a file ID.

File

execute()

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

Drive.Files.Get

setForm(String form)

Sets the response data format.

Drive.Files.Get

setPrettyPrint(Boolean prettyPrint)

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

Drive.Files.Get

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.

void

executeContentAndDownloadTo(java.io.OutputStream outputStream)

Sends a media request to the server and writes the input stream of returned media content into the specified destination output stream.

java.io.InputStream

executeContentAsInputStream()

Sends a media request to the server and returns a media content input stream.

HttpResponse

executeContent()

Sends a media request to the server and returns media content.

Boolean

getAcknowledgeDownloadRisk()

Checks whether a user acknowledges the download of known malware or files incurring risks.

Drive.Files.Get

setAcknowledgeDownloadRisk(Boolean acknowledgeDownloadRisk)

Sets whether a user acknowledges the download of known malware or files incurring risks.

boolean

isAcknowledgeDownloadRisk()

Determines whether a user acknowledges the download of known malware or files incurring risks

Protected Constructors

constructor
protected Drive.Files.Get(String fileId)
Constructs a the Drive.Files.Get object.

Parameters

Parameter nameParameter desc
fileIdFile ID, which is returned when a file list is obtained through the Files.list API.

Public Methods

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

Parameters

Parameter nameParameter desc
fields

Fields to be contained in a response, that is, attributes of a File object, for example, category, fileName, and size. If fields is set to asterisk (*), all attributes of a File object are returned.

If fields is not set, the category, id, fileName, and mimeType attributes are returned by default.

Return

typedesc
Drive.Files.GetA Drive.Files.Get object.
Method


public Drive.Files.Get 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.GetA Drive.Files.Get object.
Method


public String getFileId()

Obtains a file ID.

Return

typedesc
StringFile ID.
Method


public Drive.Files.Get setFileId(String fileId)

Sets a file ID.

Parameters

Parameter nameParameter desc
fileIdFile ID.

Return

typedesc
Drive.Files.GetA Drive.Files.Get object.
Method


public void executeContentAndDownloadTo (java.io.OutputStream outputStream)

Sends a media request to the server and writes the input stream of returned media content into the specified destination output stream.

Parameters

Parameter nameParameter desc
outputStreamSpecified output stream.
Method


public java.io.InputStream executeContentAsInputStream ()

Sends a media request to the server and returns a media content input stream.

Return

typedesc
java.io.InputStreamInput stream.
Method


public HttpResponse executeContent()

Sends a media request to the server and returns media content.

Return

typedesc
HttpResponseAn HttpResponse object.
Method


public Drive.Files.Get setForm(String form)

Sets the response data format.

Parameters

Parameter nameParameter desc
formResponse data format. The default response data format is JSON. The options of this parameter include json and content.

Return

typedesc
Drive.Files.GetA Drive.Files.Get object.
Method


public Drive.Files.Get 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.GetA Drive.Files.Get object.
Method


public Drive.Files.Get 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.

Parameters

Parameter nameParameter desc
quotaIdA 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.GetA Drive.Files.Get object.


Method

public Boolean getAcknowledgeDownloadRisk()

Checks whether a user acknowledges the download of known malware or files incurring risks.

Returns

BooleanIndicates whether a user acknowledges the download of known malware or files incurring risks.


Method
public Drive.Files.Get setAcknowledgeDownloadRisk(Boolean acknowledgeDownloadRisk)
Sets whether a user acknowledges the download of known malware or files incurring risks.

Parameters

acknowledgeDownloadRiskIndicates whether a user acknowledges the download of known malware or files incurring risks.

Returns

Drive.Files.GetA Drive.Files.Get object.


Method
public boolean isAcknowledgeDownloadRisk()
Determines whether a user acknowledges the download of known malware or files incurring risks.

Returns

booleanIndicates whether a user acknowledges the download of known malware or files incurring risks.


Method

public T execute() throws IOException

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

Throws

Parameter nameParameter desc
java.io.IOExceptionI/O exception thrown upon an API call failure. You can use the getMessage() method to obtain the error description.

Return

typedesc
FileThe Drive.Files.Get class extends DriveRequest<File>. The return result of the execute() method is encapsulated as a File object. The return result contains only the attributes specified by fields.

Sample Code

  1. private void getFile(Drive drive, String fileId){
  2.    try{
  3.        File mfile = drive.files().get(fileId).execute();
  4.    } catch (Exception e){
  5.        Log.e(TAG, "getFile error: " + e.toString());
  6.    }
  7. }