|
Google Drive for Unity3D
|
Google Drive for Unity3D. More...
Classes | |
| class | AsyncSuccess |
| Success result. More... | |
| class | Exception |
| Exception with error code. More... | |
| class | File |
| File class. More... | |
| struct | RevokeResponse |
| Response of 'revoke'. | |
| struct | TokenInfoResponse |
| Response of 'tokeninfo'. | |
| struct | TokenResponse |
| Response of 'token'. | |
Public Member Functions | |
| GoogleDrive () | |
| Constructor. | |
| IEnumerator | Authorize () |
| Start authorization. | |
| IEnumerator | Unauthorize () |
| Unauthorize and remove the saved session. | |
| IEnumerator | GetFile (string id) |
| Get a file metadata. | |
| IEnumerator | ListAllFiles () |
| Get all files. | |
| IEnumerator | ListFiles (File parentFolder) |
| Get files in a folder with Folder File. | |
| IEnumerator | ListFilesByQuery (string query) |
| Get files by a searching query.https://developers.google.com/drive/search-parameters | |
| IEnumerator | InsertFolder (string title) |
| Insert a folder to the root folder. | |
| IEnumerator | InsertFolder (string title, File parentFolder) |
| Insert a folder to otehr folder. | |
| IEnumerator | DeleteFile (File file) |
| Delete a file(or folder). | |
| IEnumerator | UpdateFile (File file) |
| Update file's metadata.You can change Title, Description, MimeType and Parents. | |
| IEnumerator | TouchFile (File file) |
| Touch a file(or folder). | |
| IEnumerator | DuplicateFile (File file, string newTitle) |
| Duplicate a file in the same folder. | |
| IEnumerator | DuplicateFile (File file, string newTitle, File newParentFolder) |
| Duplicate a file in a specified folder. | |
| IEnumerator | UploadFile (string title, string mimeType, byte[] data) |
| Upload a file to the root folder. | |
| IEnumerator | UploadFile (string title, string mimeType, File parentFolder, byte[] data) |
| Upload a file. | |
| IEnumerator | UploadFile (File file, byte[] data) |
| Upload a file. | |
| IEnumerator | DownloadFile (File file) |
| Download a file content. | |
| IEnumerator | DownloadFile (string url) |
| Download a file content. | |
Static Public Member Functions | |
| static T | GetResult< T > (IEnumerator async) |
| Get the result from AsyncSuccess. | |
| static bool | IsDone (IEnumerator async) |
| Check the async operation is done. | |
Properties | |
| string | ClientID [get, set] |
| Google Drive Application Client ID. | |
| string | ClientSecret [get, set] |
| Google Drive Application Secret Key. | |
| bool | IsAuthorized [get, set] |
| Is Google Drive authorized. | |
| string | UserAccount [get, set] |
| User's E-Mail address. | |
| File | AppData [get, set] |
| AppData folder.https://developers.google.com/drive/appdata | |
Google Drive for Unity3D.
| GoogleDrive.GoogleDrive | ( | ) |
Constructor.
| IEnumerator GoogleDrive.Authorize | ( | ) |
Start authorization.
var drive = new GoogleDrive(); drive.ClientID = "YOUR CLIENT ID"; // unnecessary to Android drive.ClientSecret = "YOUR CLIENT SECRET"; // unnecessary to Android var authorization = drive.Authorize(); yield return StartCoroutine(authorization); if (authorization.Current is Exception) { Debug.LogError(authorization.Current as Exception); return; } do something;
| IEnumerator GoogleDrive.DeleteFile | ( | File | file | ) |
Delete a file(or folder).
| file | File. |
Delete all files.
var listFiles = drive.ListAllFiles();
yield return StartCoroutine(listFiles);
var files = GoogleDrive.GetResult<List<GoogleDrive.File>>(listFiles);
if (files != null)
{
for (int i = 0; i < files.Count; i++)
yield return StartCoroutine(drive.DeleteFile(files[i]));
}
| IEnumerator GoogleDrive.DownloadFile | ( | File | file | ) |
Download a file content.
| file | File. |
Download a file and print text.
var download = drive.DownloadFile(file);
yield return StartCoroutine(download);
var data = GoogleDrive.GetResult<byte[]>(download);
if (data != null)
print(System.Text.Encoding.UTF8.GetString(data));
| IEnumerator GoogleDrive.DownloadFile | ( | string | url | ) |
Download a file content.
| file | Download URL. |
Download the thumbnail image.
if (file.ThumbnailLink != null) { var download = drive.DownloadFile(file.ThumbnailLink); yield return StartCoroutine(drive); var data = GoogleDrive.GetResult<byte[]>(download); if (data != null) someTexture.LoadImage(data); }
| IEnumerator GoogleDrive.DuplicateFile | ( | File | file, |
| string | newTitle | ||
| ) |
Duplicate a file in the same folder.
| file | File to duplicate. |
| newTitle | New filename. |
Copy a file in the same folder.
string newTitle = someFile.Title + "(2)"; StartCoroutine(drive.DuplicateFile(someFile, newTitle));
Duplicate a file in a specified folder.
| file | File to duplicate. |
| newTitle | New filename. |
| newParentFolder | New parent folder. If it is null then the new file will place in root folder. |
Copy a file to the root folder.
StartCoroutine(drive.DuplicateFile(someFile, someFile.Title, null));
| IEnumerator GoogleDrive.GetFile | ( | string | id | ) |
Get a file metadata.
| id | File ID. |
| static T GoogleDrive.GetResult< T > | ( | IEnumerator | async | ) | [static] |
Get the result from AsyncSuccess.
| T | Type of result. |
| async | Async routine. |
var listFiles = drive.ListFiles(drive.AppData);
yield return StartCoroutine(listFiles);
var files = GoogleDrive.GetResult<List<GoogleDrive.File>>(listFiles);
if (files != null)
do something;
| IEnumerator GoogleDrive.InsertFolder | ( | string | title | ) |
Insert a folder to the root folder.
var insert = drive.InsertFolder("new_folder_in_root"); yield return StartCoroutine(insert);
| IEnumerator GoogleDrive.InsertFolder | ( | string | title, |
| File | parentFolder | ||
| ) |
Insert a folder to otehr folder.
| parentFolder | Parent folder. |
var insert = drive.InsertFolder("new_folder_in_appdata", drive.AppData); yield return StartCoroutine(insert);
| static bool GoogleDrive.IsDone | ( | IEnumerator | async | ) | [static] |
Check the async operation is done.
| async | Async operation. |
| IEnumerator GoogleDrive.ListAllFiles | ( | ) |
Get all files.
Get all files that you can see.
var listFiles = drive.ListAllFiles();
yield return StartCoroutine(listFiles);
var files = GoogleDrive.GetResult<List<GoogleDrive.File>>(listFiles);
| IEnumerator GoogleDrive.ListFiles | ( | File | parentFolder | ) |
Get files in a folder with Folder File.
| parentFolder | Folder File. |
Get all files located directly under AppData.
var listFiles = drive.ListFiles(drive.AppData);
yield return StartCoroutine(listFiles);
var files = GoogleDrive.GetResult<List<GoogleDrive.File>>(listFiles);
| IEnumerator GoogleDrive.ListFilesByQuery | ( | string | query | ) |
Get files by a searching query.https://developers.google.com/drive/search-parameters
| query | Query string. |
Search by title.
var listFiles = drive.ListFilesByQuery("title = 'some_title.txt'"); yield return StartCoroutine(listFiles); var files = GoogleDrive.GetResult<List<GoogleDrive.File>>(listFiles); if (files != null && files.Count > 0) do something;
| IEnumerator GoogleDrive.TouchFile | ( | File | file | ) |
Touch a file(or folder).
| file | File to touch. |
StartCoroutine(drive.TouchFile(someFile));
| IEnumerator GoogleDrive.Unauthorize | ( | ) |
Unauthorize and remove the saved session.
StartCoroutine(drive.Unauthorize());
| IEnumerator GoogleDrive.UpdateFile | ( | File | file | ) |
Update file's metadata.You can change Title, Description, MimeType and Parents.
| file | Updated file. |
Rename 'a.txt' to 'b.txt'.
var listFiles = drive.ListFilesByQuery("title = 'a.txt'"); yield return StartCoroutine(listFiles); var files = GoogleDrive.GetResult<List<GoogleDrive.File>>(listFiles); if (files != null && files.Count > 0) { files[0].Title = "b.txt"; yield return StartCoroutine(drive.UpdateFile(files[0])); }
| IEnumerator GoogleDrive.UploadFile | ( | string | title, |
| string | mimeType, | ||
| File | parentFolder, | ||
| byte[] | data | ||
| ) |
Upload a file.
| title | Filename. |
| mimeType | Content type. |
| parentFolder | Parent folder. null is the root folder. |
| data | Data. |
Upload a file in AppData.
var bytes = Encoding.UTF8.GetBytes("world!"); StartCoroutine(drive.UploadFile("hello.txt", "text/plain", drive.AppData, bytes));
| IEnumerator GoogleDrive.UploadFile | ( | string | title, |
| string | mimeType, | ||
| byte[] | data | ||
| ) |
Upload a file to the root folder.
| title | Filename. |
| mimeType | Content type. |
| data | Data. |
var bytes = Encoding.UTF8.GetBytes("world!"); StartCoroutine(drive.UploadFile("hello.txt", "text/plain", bytes));
| IEnumerator GoogleDrive.UploadFile | ( | File | file, |
| byte[] | data | ||
| ) |
Upload a file.
| file | File metadata. |
| data | Data. |
Upload a file to the root folder.
var bytes = Encoding.UTF8.GetBytes("world!"); var file = new GoogleDrive.File(new Dictionary<string, object> { { "title", "hello.txt" }, { "mimeType", "text/plain" }, }); StartCoroutine(drive.UploadFile(file, bytes));
Update the file content.
var listFiles = drive.ListFilesByQuery("title = 'a.txt'"); yield return StartCoroutine(listFiles); var files = GoogleDrive.GetResult<List<GoogleDrive.File>>(listFiles); if (files != null && files.Count > 0) { var bytes = Encoding.UTF8.GetBytes("new content."); StartCoroutine(drive.UploadFile(files[0], bytes)); }
File GoogleDrive.AppData [get, set] |
AppData folder.https://developers.google.com/drive/appdata
string GoogleDrive.ClientID [get, set] |
Google Drive Application Client ID.
string GoogleDrive.ClientSecret [get, set] |
Google Drive Application Secret Key.
Android doesn't need this value.
bool GoogleDrive.IsAuthorized [get, set] |
Is Google Drive authorized.
string GoogleDrive.UserAccount [get, set] |
User's E-Mail address.