| class info |
| public class Drive.Files.Create extends DriveRequest<File> |
| Drive.Files.Create class. |
| 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. |
| Return type | Method 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. |
| constructor |
| protected Drive.Files.Create (File content) |
| Constructs a Drive.Files.Create object. |
Parameters
| Parameter name | Parameter desc |
| content | File object. |
| constructor |
protected Drive.Files.Create (File content,AbstractInputStreamContent mediaContent) |
| Constructs a Drive.Files.Create object. |
Parameters
| Parameter name | Parameter desc |
| 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
| Parameter name | Parameter desc |
| fields | Fields to be contained in a response. An asterisk (*) can be used to match all related fields. |
Return
| type | desc |
| 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
| Parameter name | Parameter desc |
| parameterName | Parameter name. |
| value | Parameter value. |
Return
| type | desc |
| Drive.Files.Create | A Drive.Files.Create object. |
| Method |
public Drive.Files.Create setForm(String form) |
| Sets the response data format. |
Parameters
| Parameter name | Parameter desc |
| form | Response data format. The default data format is JSON, and only this format is supported currently. |
Return
| type | desc |
| 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 line-wrapping breaks. |
Parameters
| Parameter name | Parameter desc |
| prettyPrint | Indicates whether to return a response containing indentations and line-wrapping breaks. The value is of the Boolean type. |
Return
| type | desc |
| Drive.Files.Create | A 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 name | Parameter desc |
| 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. |
Return
| type | desc |
| 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
| Parameter name | Parameter 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
| type | desc |
| File | The Drive.Files.Create class extends DriveRequest<File>. The return result of the execute() method is encapsulated as a File object. |
Sample Code
- 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.toString());
- }
- }