目录

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

Protected Constructor Summary

Constructor name

Drive.Files.Create(File content) 

Constructor for the Drive.Files.Create class for creating a folder.

Drive.Files.Create(File content, AbstractInputStreamContent mediaContent) 

Constructor for the Drive.Files.Create class for creating a file.

Public Method Summary

Return typeMethod name
Drive.Files.Create

setFields(String fields)

Sets the fields to be contained in a response.

Drive.Files.Create

set(String parameterName, Object value)

Sets the given parameter value for the given parameter name.

File

execute()

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

Drive.Files.Create

setForm(String form)

Sets the response data format.

Drive.Files.Create

setPrettyPrint(Boolean prettyPrint)

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

Drive.Files.Create

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.Create (File content)
Constructs a Drive.Files.Create object.

Parameters

Parameter nameParameter desc
contentFile object.
constructor


protected Drive.Files.Create (File content,AbstractInputStreamContent mediaContent)

Constructs a Drive.Files.Create object.

Parameters

Parameter nameParameter desc
contentFile object.
mediaContentHTTP media content.

Public Methods

Method
public Drive.Files.Create 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.CreateA Drive.Files.Create object.
Method


public Drive.Files.Create 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.CreateA Drive.Files.Create object.
Method


public Drive.Files.Create 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.CreateA Drive.Files.Create object.
Method


public Drive.Files.Create 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.CreateA Drive.Files.Create object.
Method


public Drive.Files.Create 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
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.CreateA Drive.Files.Create object.
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.Create class extends DriveRequest<File>. The return result of the execute() method is encapsulated as a File object.


Sample Code

  1. private void createFiles(Drive drive, String type, String filePath){
  2.    try{
  3.        // Create a folder.
  4.        File dir = new File().setFileName ("testDir").setMimeType("application/vnd.huawei-apps.folder");
  5.        File directory = drive.files().create(dir).execute();
  6.        // Create (or upload) a file.
  7.        FileContent fileContent = new FileContent(type, new java.io.File(filePath));
  8.        File fileInfo = new File().setFileName ("testFile");
  9.        File mFile = drive.files().create(fileInfo, fileContent).execute();
  10.    } catch (Exception e){
  11.        Log.e(TAG, "createFiles error: " + e.toString());
  12.    }
  13. }