Class Info |
|---|
public class Drive.Files.Create extends DriveRequest<File> Drive.Files.Create class. |
Constructor Name |
|---|
Drive.Files.Create(File content) Constructs a Drive.Files.Create object for creating a folder. |
Drive.Files.Create(File content, AbstractInputStreamContent mediaContent) Constructs a Drive.Files.Create object for creating a file. |
Qualifier and Type | Method Name and Description |
|---|---|
execute() Sends an HTTP request and returns the object to be converted. | |
set(String parameterName, Object value) Sets the given parameter value for the given parameter name. | |
setFields(String fields) Sets the fields to be contained in a response. Note: If fields is set to *, sharer, sharedWithMeTime, hasShared, capabilities, permissions, and permissionIds in drive#file are not returned. | |
setForm(String form) Sets the response data format. | |
setPrettyPrint(Boolean prettyPrint) Sets whether to return a response containing indentations and newline characters. | |
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. |
Constructor |
|---|
protected Drive.Files.Create(File content) Constructs a Drive.Files.Create object. |
Parameters
Name | Description |
|---|---|
content | File object. |
Constructor |
|---|
protected Drive.Files.Create(File content,AbstractInputStreamContent mediaContent) Constructs a Drive.Files.Create object. |
Parameters
Name | Description |
|---|---|
content | File object. |
mediaContent | HTTP media content. |
Method |
|---|
public Drive.Files.Create setFields(String fields) Sets the fields to be contained in a response. |
Parameters
Name | Description |
|---|---|
fields | Fields to be contained in a response. An asterisk (*) can be used to match all related fields. Note: If fields is set to *, sharer, sharedWithMeTime, hasShared, capabilities, permissions, and permissionIds in drive#file are not returned. |
Returns
Type | Description |
|---|---|
Drive.Files.Create | A 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
Name | Description |
|---|---|
parameterName | Parameter name. |
value | Parameter value. |
Returns
Type | Description |
|---|---|
Drive.Files.Create | A Drive.Files.Create object. |
Method |
|---|
public Drive.Files.Create setForm(String form) Sets the response data format. |
Parameters
Name | Description |
|---|---|
form | Response data format. The default data format is json, and only this format is supported currently. |
Returns
Type | Description |
|---|---|
Drive.Files.Create | A Drive.Files.Create object. |
Method |
|---|
public Drive.Files.Create setPrettyPrint(Boolean prettyPrint) Sets whether to return a response containing indentations and newline characters. |
Parameters
Name | Description |
|---|---|
prettyPrint | Indicates whether to return a response containing indentations and newline characters. The value is a Boolean value. |
Returns
Type | Description |
|---|---|
Drive.Files.Create | A Drive.Files.Create object. |
Method |
|---|
public 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. |
Parameters
Name | Description |
|---|---|
quotaId | 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. |
Returns
Type | Description |
|---|---|
Drive.Files.Create | A Drive.Files.Create object. |
Method |
|---|
public T execute() throws IOException Sends an HTTP request and returns the object to be converted. |
Throws
Name | Description |
|---|---|
java.io.IOException | I/O exception thrown upon an API call failure. You can use the getMessage method to obtain the error description. |
Returns
Type | Description |
|---|---|
File | The Drive.Files.Create class inherits DriveRequest<File>. Therefore, the return result of the execute() method is encapsulated as a File object. |
private void createFiles(Drive drive, String type, String filePath){
try{
// Create a folder.
File dir = new File().setFileName("testDir")
.setMimeType("application/vnd.huawei-apps.folder");
File directory = drive.files().create(dir).execute();
// Create or upload a file.
FileContent fileContent = new FileContent(type, new java.io.File(filePath));
File fileInfo = new File().setFileName("testFile");
File mFile = drive.files().create(fileInfo, fileContent).execute();
} catch (Exception e){
Log.e(TAG, "createFiles error:" + e.getMessage());
}
}