Step 4: Now depending on your file, you can tap Save Image or Save Video. Step 2: Next to file you want to download, tap More (three dots). Step 1: First open the Google Drive app on your device. Now you can save a photo or video to your camera roll.
How to download a file from Google drive using iPhone String path = fileHandler.GetCategoryImagePath(category.Id + ".jpg") įileHandler.SaveAppImage(path, image.texture = fileHandler.GetCategoryImage(category.Id + ".Step 2: Next to the file's name, tap More. Lines below are my custom lines of codes which saves images and sets as a texture to a RawImage UnityWebRequest www = UnityWebRequestTexture.GetTexture(downloadAddress) String downloadAddress = fileDownloader.GetGoogleDriveDownloadAddress(category.ImageUrl) FileDownloader fileDownloader = new FileDownloader() I could download my images from google drive using the downloadAddress FileDownloader GetGoogleDriveDownloadAddress() method generated. My app made approximately 100 calls on a short time. Is it a Google issue? I have 27 images at 22-220 KB size range on google drive. When I copy-pasted downloadAddress on the browser it downloads. It gives nothing on DownloadFileCompleted event. Concat( " ", fileID, "&export=download&confirm=t " )
Concat( " ", fileID, "&export=download&resourcekey= ", resourceKey, "&confirm=t " ) Substring( index, closingIndex - index ) Private string GetGoogleDriveDownloadAddress( string address )ĬlosingIndex = address. - /uc?id=FILEID&export=download&resourcekey=RESOURCEKEY - /file/d/FILEID/view?usp=sharing&resourcekey=RESOURCEKEY Handles the following formats (links can be preceeded by // - /open?id=FILEID&resourcekey=RESOURCEKEY Substring( linkIndex, linkEnd - linkIndex ). IndexOf( '"', linkIndex ) ĭownloadAddress = new Uri( " " + content. Confirmation page starts with, which can be preceeded by a newline Downloaded file might be the confirmation page, check it Private void DownloadFileCompletedCallback( object sender, AsyncCompletedEventArgs e ) TotalBytesToReceive ĭownloadProgressChanged( this, downloadProgress )
Private WebResponse ProcessResponse( WebResponse response ) Protected override WebResponse GetWebResponse( WebRequest request ) Protected override WebResponse GetWebResponse( WebRequest request, IAsyncResult result ) Protected override WebRequest GetWebRequest( Uri address ) Public DownloadProgress ContentRangeTarget Private readonly CookieContainer cookies = new CookieContainer() Private readonly Dictionary cookies = new Dictionary() Private class CookieAwareWebClient : WebClient Web client that preserves cookies (needed for Google Drive) Return ( int) ( ( ( double) BytesReceived / TotalBytesToReceive ) * 100 ) Public long BytesReceived, TotalBytesToReceive Custom download progress reporting (needed for Google Drive) Public delegate void DownloadProgressChangedEventHandler( object sender, DownloadProgress progress ) Private const int GOOGLE_DRIVE_MAX_DOWNLOAD_ATTEMPT = 3 an NID cookie is returned instead of a download_warning cookie In the worst case, it is necessary to send 3 download requests to the Drive address Private const string GOOGLE_DRIVE_DOMAIN2 = " " Private const string GOOGLE_DRIVE_DOMAIN = " " Public class FileDownloader : IDisposable This callback is triggered for both DownloadFile and DownloadFileAsyncįileDownloader.DownloadFileCompleted += ( sender, e ) => Console.WriteLine( "Download completed" ) This callback is triggered for DownloadFileAsync onlyįileDownloader.DownloadProgressChanged += ( sender, e ) => Console.WriteLine( "Progress changed " + e.BytesReceived + " " + e.TotalBytesToReceive )