static void UploadContentManifest(WWWUtils.Environment env, string url, int enabled) { var stoken = WWWUtils.AdminLogin(env); var postUrl = WWWUtils.GetAdminUrl(env) + "/bundlemanager/content/from-manifest?stoken=" + stoken; var form = new WWWForm(); form.AddField("url", url); form.AddField("enabled", enabled); WWWUtils.Post(postUrl, form); }
public static string PutData(byte[] bytes, string name, string path) { var key = Path.Combine(BasePath, path); Debug.LogFormat("S3 Put: {0} -> {1}:/{2}", name, Bucket, key); if (string.IsNullOrEmpty(Bucket)) { return(string.Empty); } WWWForm form = new WWWForm(); form.AddField("key", key); form.AddField("acl", "public-read"); form.AddField("AWSAccessKeyId", AccessKeyId); form.AddField("Policy", Policy); form.AddField("Signature", Signature); form.AddBinaryData("file", bytes, name); var contentType = MimeUtils.GetMimeType(Path.GetExtension(name)); if (!string.IsNullOrEmpty(contentType)) { form.AddField("Content-Type", contentType); } // make sure to upload the md5 form.AddField("Content-MD5", CalculateMD5(bytes)); var url = "http://" + Bucket + ".s3.amazonaws.com/"; var result = WWWUtils.Post(url, form); Debug.LogFormat("key {0} result: {1}", key, result); if (result.Contains("Error")) { throw new System.Exception("S3 upload failed! key: " + key + " result: " + result); } // GC System.GC.Collect(); // return the url return(url + key); }
static void UploadApkFiles(string apkPath, WWWUtils.Environment env) { try { var tmpDir = "/tmp/apk"; GeneralUtils.DeleteDirectory(tmpDir, true); // mko: cleaning up build folder Directory.CreateDirectory(tmpDir); // unzip var res = CommandLineUtils.Run("/usr/bin/unzip", string.Format("-d {0} {1}", tmpDir, apkPath)); Debug.Log(res); // generate the app.dll var files = new List <string>(Directory.GetFiles("/tmp/apk/assets/bin/Data/Managed", "*.dll", SearchOption.TopDirectoryOnly)); files.Sort(System.StringComparer.OrdinalIgnoreCase); List <byte> bytes = new List <byte>(); foreach (string filePath in files) { Debug.Log("Adding file " + filePath); bytes.AddRange(File.ReadAllBytes(filePath)); } Debug.Log("MSIL size is " + EB.Localizer.FormatNumber(bytes.Count, true)); WWWForm form = new WWWForm(); form.AddBinaryData("data", bytes.ToArray(), "data"); form.AddField("version", EB.Version.GetVersion()); form.AddField("platform", "android"); form.AddField("sha1", EB.Encoding.ToBase64String(EB.Digest.Sha1().Hash(bytes.ToArray()))); var stoken = WWWUtils.AdminLogin(env); var postUrl = WWWUtils.GetAdminUrl(env) + "/protect/upload?stoken=" + stoken; res = WWWUtils.Post(postUrl, form); Debug.Log("version: " + res); } catch (System.Exception e) { Debug.Log("Build Failed: exception: " + e.ToString()); Failed(e); } }