GooglePlayInstant/Editor/QuickDeploy/GcpClient.cs
/// <summary>
/// Uploads configured file to GCP and makes the file public.
/// </summary>
/// <exception cref="Exception">Exception thrown if there was an error uploading the bundle or setting the
/// visibility of file to public.</exception>
Uploads configured file to GCP and makes the file public.
Uploads configured file to GCP and makes the file public .
private static void UploadBundleAndMakePublic()
        {
            InvokeAccessRestrictedAction(UploadBundleFile, uploadBundleWww =>
            {
                if (!string.IsNullOrEmpty(uploadBundleWww.error))
                {
                    throw new Exception(string.Format("Error uploading bundle: {0}\n{1}", uploadBundleWww.error,
                        uploadBundleWww.text));
                }
                Debug.Log("Uploaded bundle to Google Cloud Platform.");
                var response = JsonUtility.FromJson<FileUploadResponse>(uploadBundleWww.text);
                var bucketName = response.bucket;
                var fileName = response.name;
                if (bucketName != QuickDeployWindow.Config.CloudStorageBucketName)
                {
                    throw new Exception(string.Format(
                        "Response bucket name \"{0}\" doesn't match expected name \"{1}\"",
                        bucketName, QuickDeployWindow.Config.CloudStorageBucketName));
                }
                if (fileName != QuickDeployWindow.Config.CloudStorageObjectName)
                {
                    throw new Exception(string.Format(
                        "Response file name \"{0}\" doesn't match expected name \"{1}\"",
                        fileName, QuickDeployWindow.Config.CloudStorageObjectName));
                }
                QuickDeployWindow.Config.AssetBundleUrl =
                    string.Format("https://storage.googleapis.com/{0}/{1}", bucketName, fileName);
                InvokeAccessRestrictedAction(MakeBundlePublic, makeBundlePublicWww =>
                {
                    var error = makeBundlePublicWww.error;
                    if (!string.IsNullOrEmpty(error))
                    {
                        throw new Exception(string.Format("Error making file public: {0}\n{1}", error,
                            makeBundlePublicWww.text));
                    }
                    Debug.Log("Set visibility of deployed file to public.");
                });
            });
        }
private static void UploadBundleAndMakePublic ( ) { InvokeAccessRestrictedAction ( UploadBundleFile , uploadBundleWww => { if ( ! string . IsNullOrEmpty ( uploadBundleWww . error ) ) { throw new Exception ( string . Format ( " \n " , uploadBundleWww . error , uploadBundleWww . text ) ) ; } Debug . Log ( " " ) ; var response = JsonUtility . FromJson < FileUploadResponse > ( uploadBundleWww . text ) ; var bucketName = response . bucket ; var fileName = response . name ; if ( bucketName != QuickDeployWindow . Config . CloudStorageBucketName ) { throw new Exception ( string . Format ( " \" \" \" \" " , bucketName , QuickDeployWindow . Config . CloudStorageBucketName ) ) ; } if ( fileName != QuickDeployWindow . Config . CloudStorageObjectName ) { throw new Exception ( string . Format ( " \" \" \" \" " , fileName , QuickDeployWindow . Config . CloudStorageObjectName ) ) ; } QuickDeployWindow . Config . AssetBundleUrl = string . Format ( " " , bucketName , fileName ) ; InvokeAccessRestrictedAction ( MakeBundlePublic , makeBundlePublicWww => { var error = makeBundlePublicWww . error ; if ( ! string . IsNullOrEmpty ( error ) ) { throw new Exception ( string . Format ( " \n " , error , makeBundlePublicWww . text ) ) ; } Debug . Log ( " " ) ; } ) ; } ) ; }
Uploads configured file to GCP and makes the file public.
Uploads configured file to GCP and makes the file public .
Exception thrown if there was an error uploading the bundle or setting the
visibility of file to public.
Exception thrown if there was an error uploading the bundle or setting the visibility of file to public .