Unity download file from google drive
I'm currently making two programs for work in Unity on two separate computers. I have managed to read a local text file on the main computer and upload the info into a google sheets document. For security reasons, I understand that it is not possible to then access the drive on the second computer and download the sheet as a csv file locally. Is there another way I can access the sheet data on the second computer from google drive without having to download it manually each morning? Show
asked Apr 8 at 12:18
1 I suggest you do the following:
There is 1 problem with this, is that your info will be accessible publicly by anyone who has the link, this is a simple way to do it for testing for now. answered Apr 8 at 12:22
Dean Van GreunenDean Van Greunen 4,0522 gold badges14 silver badges27 bronze badges 1 November 15, 2017 Assembled a plugin for Unity engine to work with Google Drive. The plugin provides API for listing, searching, creating, uploading, editing, copying, downloading and deleting files; works with Unity version 5.6 and higher and supports all major target platforms (including WebGL). Project on GitHub (MIT license): github.com/Elringus/UnityGoogleDrive. Read NextSeptember 14, 2016 UI distortion in Unreal EngineOpensource Glitch Shader Ue4 April 12, 2018 Using Raw Input API in UnityOpensource Control Event Native Keyboard TagsCloud Storage for Firebase allows you to quickly
and easily download files from a Cloud Storage bucket provided and managed by Firebase. To download a file, first create a Cloud Storage reference to the file you want to download. You can create a reference by appending child paths to the root of
your Cloud Storage bucket, or you can create a reference from an existing Once you have a reference, you can download files from Cloud Storage in four ways: The method you will use to retrieve your files will
depend on how you want to consume the data in your game. Download from a URLIf you want to use a URL with Unity's // Fetch the download URL reference.GetDownloadUrlAsync().ContinueWithOnMainThread(task => { if (!task.IsFaulted && !task.IsCanceled) { Debug.Log("Download URL: " + task.Result); // ... now download the file via WWW or UnityWebRequest. } }); Download to a byte arrayYou can download the file to a byte buffer in memory using the // Download in memory with a maximum allowed size of 1MB (1 * 1024 * 1024 bytes) const long maxAllowedSize = 1 * 1024 * 1024; reference.GetBytesAsync(maxAllowedSize).ContinueWithOnMainThread(task => { if (task.IsFaulted || task.IsCanceled) { Debug.LogException(task.Exception); // Uh-oh, an error occurred! } else { byte[] fileContents = task.Result; Debug.Log("Finished downloading!"); } }); Download via a StreamDownloading the file with a Stream allows you to process the data as its loaded. This gives you maximum flexibility when dealing with your download. Call // Download via a Stream reference.GetStreamAsync(stream => { // Do something with the stream here. // // This code runs on a background thread which reduces the impact // to your framerate. // // If you want to do something on the main thread, you can do that in the // progress eventhandler (second argument) or ContinueWith to execute it // at task completion. }, null, CancellationToken.None);
Download to a local fileThe // Create local filesystem URL string localUrl = "file:///local/images/island.jpg"; // Download to the local filesystem reference.GetFileAsync(localUrl).ContinueWithOnMainThread(task => { if (!task.IsFaulted && !task.IsCanceled) { Debug.Log("File downloaded."); } }); You can attach listeners to downloads in order to monitor the progress of the download. The listener follows the
standard // Create local filesystem URL string localUrl = "file:///local/images/island.jpg"; // Start downloading a file Task task = reference.GetFileAsync(localFile, new StorageProgress Handle ErrorsThere are a number of reasons why errors may occur on download, including the file not existing, or the user not having permission to access the desired file. More information on errors can be found in the Handle Errors section of the docs. Next StepsYou can also get and update metadata for files that are stored in Cloud Storage. Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Last updated 2022-11-07 UTC. [{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }] [{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }] How do I access Google Drive from C#?Introduction to Google Drive API Version 3. Log into your Google account.. Register your application in Google API Console from here this URL.. Create a new project by clicking on the "Continue" button.. Click on the "Cancel" button.. Go to "OAuth consent screen".. Enter the application name and click "Save".. Does Google support Unity?Stay organized with collections Save and categorize content based on your preferences. Google's official packages for Unity extend the default capabilities of Unity, enabling you to optimize game performance, reach new users, understand user behavior, and more.
How do I download files from Google Drive Unity?Import the package; In the Unity editor navigate to Edit -> Settings -> Google Drive ; GoogleDriveSettings. asset file will be automatically created at Assets/UnityGoogleDrive/Resources , select the file (if it wasn't selected automatically);
|