Created
January 4, 2019 07:53
-
-
Save voxelbustersold/df0a84ef7d890da0086b3b1e62e33f55 to your computer and use it in GitHub Desktop.
Copy any file to Persistent Path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Namespace for using utility functions | |
using VoxelBusters.InstagramKit.Common.Utility; | |
// Path can be from local or web | |
private void DownloadFileToPersistentPath(string filePath, string targetFileName) | |
{ | |
// Downloading if the file doesn't exist | |
if (!FileOperations.Exists (Application.persistentDataPath + "/" + targetFileName)) | |
{ | |
// Download file from given path | |
DownloadAsset _newDownload = new DownloadAsset (new URL (filePath), true); | |
_newDownload.OnCompletion = (WWW _www, string _error) => { | |
Debug.Log (string.Format ("[DownloadAsset] Asset download completed. Error= {0}.", _error.GetPrintableString ())); | |
FileOperations.WriteAllBytes (Application.persistentDataPath + "/" + targetFileName, _www.bytes); | |
}; | |
// Start download | |
_newDownload.StartRequest (); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment