Exemplo n.º 1
0
        public void OnAfterBuild(string buildLocation, BuildReport report)
        {
            if (ZipBuild)
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                string    outPath   = $"{buildLocation}/../{Path.GetFileName(buildLocation)}.zip";
                Debug.Log("Compressing build...");
                ZipUtility.CompressFolderToZip(outPath, null, buildLocation);

                stopwatch.Stop();
                Debug.Log($"Compressed build to {outPath}. Took {stopwatch.Elapsed.Seconds}s to compress.");
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Uploads file to server, if it is folder Zips the folder - Not used in case of upload to AmazonS3.
 /// Note - As the backend server supports only upload to AmazonS3 this is never called
 /// </summary>
 /// <param name="dataPath">Path of file/folder to be uploaded</param>
 public void UploadToServer(string dataPath)
 {
     if (FileBrowserHelpers.DirectoryExists(dataPath))
     {
         string zipPath = Path.Combine(Application.persistentDataPath, "Temp.zip");
         ZipUtility.CompressFolderToZip(zipPath, null, dataPath);
         if (FileBrowserHelpers.GetFilesize(zipPath) < MaxUploadFileSize)
         {
             StartCoroutine(UploadFileToServer(zipPath, true));
         }
         else
         {
             DisplayUploadErrorMessage("File size is too large. It must be less than 50MB.");
         }
     }
     else
     {
         StartCoroutine(UploadFileToServer(dataPath, false));
     }
 }
Exemplo n.º 3
0
        public void CompressAndDecompress()
        {
            //Compress code
            string tempZipPath    = FileUtil.GetUniqueTempPathInProject();
            string runtimeSrcPath = "Packages/com.unity.sharp-zip-lib/Runtime";

            ZipUtility.CompressFolderToZip(tempZipPath, null, runtimeSrcPath);
            Assert.True(File.Exists(tempZipPath));

            //Uncompress
            string tempExtractPath = FileUtil.GetUniqueTempPathInProject();

            Directory.CreateDirectory(tempExtractPath);
            ZipUtility.UncompressFromZip(tempZipPath, null, tempExtractPath);

            string[] extractedFiles = Directory.GetFiles(tempExtractPath);
            Assert.Greater(extractedFiles.Length, 0);

            //Cleanup
            Directory.Delete(tempExtractPath, true);
            File.Delete(tempZipPath);
        }