internal static Uri GetEndpointURL(string endPoint, bool secure) { if (endPoint.Contains(":")) { string[] parts = endPoint.Split(':'); string host = parts[0]; string port = parts[1]; if (!S3Utils.IsValidIP(host) && !IsValidEndpoint(host)) { throw new InvalidEndpointException("Endpoint: " + endPoint + " does not follow ip address or domain name standards."); } } else { if (!S3Utils.IsValidIP(endPoint) && !IsValidEndpoint(endPoint)) { throw new InvalidEndpointException("Endpoint: " + endPoint + " does not follow ip address or domain name standards."); } } Uri uri = TryCreateUri(endPoint, secure); ValidateEndpoint(uri, endPoint); return(uri); }
void NextPage() { var me = RealmUserServices.GetMe(true); var realm = RealmManager.SharedInstance.GetRealm(null); //cache facebook image var str = "https://graph.facebook.com/" + Shared.FacebookUserId + "/picture?type=large"; var image = UIImage.LoadFromData(NSData.FromUrl(NSUrl.FromString(str))); var bytes = ImageUtils.ByteArrayFromImage(image, 50); S3Utils.UploadPhoto(bytes, me.LocalProfileImageURL, me.RemoteProfileImageURL, "Profile.png", null, null); Shared.NextPage(); UIView.Animate(1, delegate { View.Alpha = 0; }, delegate { if (String.IsNullOrEmpty(me.FirstName) || String.IsNullOrEmpty(me.LastName)) { ((LandingTabbarController)TabBarController).SetSelectedViewControllerByType(typeof(HelloViewController), false, null); } else { SlinkUser.SetNextHandelByNameIfNecessary(); ApplicationExtensions.ShowOnboarding(false); } }); }
public void TestIsAmazonChinaEndpoint() { Assert.IsFalse(S3Utils.IsAmazonChinaEndPoint("s3.amazonaws.com")); Assert.IsTrue(S3Utils.IsAmazonChinaEndPoint("s3.cn-north-1.amazonaws.com.cn")); Assert.IsFalse(S3Utils.IsAmazonChinaEndPoint("s3.us-west-1amazonaws.com")); Assert.IsFalse(S3Utils.IsAmazonChinaEndPoint("play.min.io")); Assert.IsFalse(S3Utils.IsAmazonChinaEndPoint("192.168.12.1")); Assert.IsFalse(S3Utils.IsAmazonChinaEndPoint("storage.googleapis.com")); }
/// <summary> /// Get canonical request. /// </summary> /// <param name="request">Instantiated request object</param> /// <param name="headersToSign">Dictionary of http headers to be signed</param> /// <returns>Canonical Request</returns> private string GetCanonicalRequest(IRestRequest request, SortedDictionary <string, string> headersToSign) { var canonicalStringList = new LinkedList <string>(); // METHOD canonicalStringList.AddLast(request.Method.ToString()); string[] path = request.Resource.Split(new char[] { '?' }, 2); if (!path[0].StartsWith("/")) { path[0] = $"/{path[0]}"; } canonicalStringList.AddLast(path[0]); string query = string.Empty; var queryParams = new List <KeyValuePair <string, string> >(); foreach (var p in request.Parameters) { if (p.Type == ParameterType.QueryString) { queryParams.Add(new KeyValuePair <string, string>(p.Name, Uri.EscapeDataString((string)p.Value))); } } var sb1 = new StringBuilder(); queryParams = queryParams.OrderBy(_ => _.Key) .ThenBy(_ => _.Value).ToList(); foreach (var p in queryParams) { if (sb1.Length > 0) { sb1.Append("&"); } sb1.AppendFormat("{0}={1}", p.Key, p.Value); } query = sb1.ToString(); canonicalStringList.AddLast(query); foreach (string header in headersToSign.Keys) { canonicalStringList.AddLast(header + ":" + S3Utils.TrimAll(headersToSign[header])); } canonicalStringList.AddLast(string.Empty); canonicalStringList.AddLast(string.Join(";", headersToSign.Keys)); if (headersToSign.Keys.Contains("x-amz-content-sha256")) { canonicalStringList.AddLast(headersToSign["x-amz-content-sha256"]); } else { canonicalStringList.AddLast(sha256EmptyFileHash); } return(string.Join("\n", canonicalStringList)); }
public void TestIfIPIsValid() { Dictionary <string, bool> testIPDict = new Dictionary <string, bool> { { "192.168.1", false }, { "192.168.1.1", true }, { "192.168.1.1.1", false }, { "-192.168.1.1", false }, { "260.192.1.1", false }, }; foreach (KeyValuePair <string, bool> testCase in testIPDict) { Assert.AreEqual(S3Utils.IsValidIP(testCase.Key), testCase.Value); } }
internal static Uri MakeTargetURL(string endPoint, bool secure, string bucketName = null, string region = null, bool usePathStyle = true) { // For Amazon S3 endpoint, try to fetch location based endpoint. string host = endPoint; if (S3Utils.IsAmazonEndPoint(endPoint)) { // Fetch new host based on the bucket location. host = AWSS3Endpoints.Instance.Endpoint(region); if (!usePathStyle) { string prefix = (bucketName != null) ? Utils.UrlEncode(bucketName) + "." : ""; host = prefix + Utils.UrlEncode(host) + "/"; } } Uri uri = TryCreateUri(host, secure); return(uri); }
void SelectImageFromGallery(string localUrl, string remoteUrl, string fileName) { if (ProfileImageButton == null) { return; } var vc = new GalleryImagePicker(); vc.Canceled += (s, e) => { vc.DismissViewController(true, null); }; vc.FinishedPickingMedia += (object s, UIImagePickerMediaPickedEventArgs e) => { switch (e.Info[UIImagePickerController.MediaType].ToString()) { case "public.image": Console.WriteLine("Image selected"); var me = RealmUserServices.GetMe(false); ProfileImageButton.SetImage(UIImage.FromBundle(FallbackImageFileName), new UIControlState()); ProfileImageButton.ShowLoadingIndicators(); UIImage originalImage = e.Info[UIImagePickerController.OriginalImage] as UIImage; var smallerImage = ImageUtils.ScaledToSize(originalImage, new CGSize(200, 200)); var bytes = ImageUtils.ByteArrayFromImage(smallerImage, 100); S3Utils.UploadPhoto(bytes, localUrl, remoteUrl, fileName, () => { SDWebImageManager.SharedManager.ImageCache.RemoveImage(me.RemoteProfileImageURL, true, null); ProfileImageButton.SetImageWithCustomCache(me.GetRemoteProfileImageUrlCached(), FallbackImageFileName, FallbackImageFileName, me.RemoteProfileImageURL); }, null); break; case "public.video": Console.WriteLine("Video selected"); break; } vc.DismissViewController(true, null); }; PresentViewController(vc, true, null); }
public override void OnActivityResult(int requestCode, int resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == SelectUserImagePhotoRequestCode && resultCode == (int)Android.App.Result.Ok) { if (data == null) { return; } using (var bitmap = MediaStore.Images.Media.GetBitmap(Activity.ContentResolver, data.Data)) { var bytes = ImageUtils.ImagetoByteArray(bitmap, 100); if (bytes == null) { return; } UserProfileImage.SetImageResource(Resource.Drawable.ic_noprofilewhite); UserProfileImage.ShowLoadingIndicators(); var me = RealmUserServices.GetMe(false); var localUrl = me.LocalProfileImageURL; var remoteUrl = me.RemoteProfileImageURL; var fileName = "Profile.png"; S3Utils.UploadPhoto(bytes, localUrl, remoteUrl, fileName, () => { if (Activity == null) { return; } Activity.RunOnUiThread(async() => { await ImageService.Instance.InvalidateCacheAsync(FFImageLoading.Cache.CacheType.All);//.InvalidateCacheEntryAsync(me.RemoteProfileImageURL, FFImageLoading.Cache.CacheType.All); UserProfileImage.SetImage(me.GetRemoteProfileImageUrlCached(), Resource.Drawable.ic_noprofilewhite, Resource.Drawable.ic_noprofilewhite, me.RemoteProfileImageURL, WebImageView.DefaultCircleTransformation); }); }, null); }; } }
/// <summary> /// Create a bucket with the given name. /// </summary> /// <param name="args">MakeBucketArgs Arguments Object that has bucket info like name, location. etc</param> /// <param name="cancellationToken">Optional cancellation token to cancel the operation</param> /// <returns> Task </returns> /// <exception cref="InvalidBucketNameException">When bucketName is invalid</exception> public async Task MakeBucketAsync(MakeBucketArgs args, CancellationToken cancellationToken = default(CancellationToken)) { args.Validate(); RestRequest request = new RestRequest("/" + args.BucketName, Method.PUT); if (string.IsNullOrEmpty(args.Location)) { args.Location = this.Region; } // Set Target URL for MakeBucket Uri requestUrl = RequestUtil.MakeTargetURL(this.BaseUrl, this.Secure, args.Location); SetTargetURL(requestUrl); // Set Authenticator, if necessary. if (string.IsNullOrEmpty(this.Region) && !S3Utils.IsAmazonEndPoint(this.BaseUrl) && args.Location != "us-east-1" && this.restClient != null) { this.restClient.Authenticator = new V4Authenticator(this.Secure, this.AccessKey, this.SecretKey, region: args.Location, sessionToken: this.SessionToken); } await this.ExecuteAsync(this.NoErrorHandlers, args.BuildRequest(request), cancellationToken); }
public void TestIsAmazonChinaEndpoint() { Dictionary <string, bool> testAmazonDict = new Dictionary <string, bool> { { "192.168.1.1", false }, { "storage.googleapis.com", false }, { "s3.amazonaws.com", false }, { "amazons3.amazonaws.com", false }, { "-192.168.1.1", false }, { "260.192.1.1", false }, { "https://s3.amazonaws.com", false }, { "s3.cn-north-1.amazonaws.com.cn", true }, }; foreach (KeyValuePair <string, bool> testCase in testAmazonDict) { bool value = S3Utils.IsAmazonChinaEndPoint(testCase.Key); Assert.AreEqual(S3Utils.IsAmazonChinaEndPoint(testCase.Key), testCase.Value); } }
void DownloadFacebookImage(string localUrl, string remoteUrl, string fileName) { if (ProfileImageButton == null) { return; } var me = RealmUserServices.GetMe(false); if (me == null) { return; } var url = me.GetFacebookProfilePictureUrl(); if (url == null) { return; } ProfileImageButton.SetImage(UIImage.FromBundle(FallbackImageFileName), new UIControlState()); ProfileImageButton.ShowLoadingIndicators(); SDWebImageManager.SharedManager.ImageDownloader.DownloadImage(NSUrl.FromString(url), SDWebImageDownloaderOptions.HighPriority, null, (image, data, error, finished) => { if (image == null || error != null) { ProfileImageButton.ShowLoadingIndicators(); return; } var bytes = ImageUtils.ByteArrayFromImage(image, 100); S3Utils.UploadPhoto(bytes, localUrl, remoteUrl, fileName, () => { SDWebImageManager.SharedManager.ImageCache.RemoveImage(me.RemoteProfileImageURL, true, null); ProfileImageButton.SetImageWithCustomCache(me.GetRemoteProfileImageUrlCached(), FallbackImageFileName, FallbackImageFileName, me.RemoteProfileImageURL); }, null); }); }
void NextPage() { var me = RealmUserServices.GetMe(true); //cache facebook image var str = "https://graph.facebook.com/" + Shared.FacebookUserId + "/picture?type=large"; var image = ImageUtils.GetImageBitmapFromUrl(str); var bytes = ImageUtils.ImagetoByteArray(image, 100); S3Utils.UploadPhoto(bytes, me.LocalProfileImageURL, me.RemoteProfileImageURL, "Profile.png", null, null); Shared.NextPage(); if (String.IsNullOrEmpty(me.FirstName) || String.IsNullOrEmpty(me.LastName)) { //((LandingTabbarController)TabBarController).SetSelectedViewControllerByType(typeof(HelloViewController), false, null); } else { SlinkUser.SetNextHandelByNameIfNecessary(); Activity.StartActivity(typeof(InstructionActivity)); } }
public override void OnActivityResult(int requestCode, int resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (resultCode == (int)Android.App.Result.Ok) { if (data == null) { return; } using (var bitmap = MediaStore.Images.Media.GetBitmap(Activity.ContentResolver, data.Data)) { var bytes = ImageUtils.ImagetoByteArray(bitmap, 100); if (bytes == null) { return; } var cell = RecyclerView.FindViewHolderForAdapterPosition(0) as CardCell; if (cell == null) { return; } var me = RealmUserServices.GetMe(false); if (requestCode == SelectUserImagePhotoRequestCode) { var imageView = cell.GetUserImageView(); imageView.SetImageResource(Resource.Drawable.ic_noprofilewhite); imageView.ShowLoadingIndicators(); var localUrl = Shared.SelectedCard.LocalHeaderURL; var remoteUrl = Shared.SelectedCard.RemoteHeaderURL; var fileName = "Header.png"; S3Utils.UploadPhoto(bytes, localUrl, remoteUrl, fileName, () => { if (Activity == null) { return; } Activity.RunOnUiThread(async() => { await ImageService.Instance.InvalidateCacheAsync(FFImageLoading.Cache.CacheType.All);//.InvalidateCacheEntryAsync(me.RemoteProfileImageURL, FFImageLoading.Cache.CacheType.All); imageView.SetImage(Shared.SelectedCard.GetRemoteHeaderUrlCached(), Resource.Drawable.ic_noprofilewhite, Resource.Drawable.ic_noprofilewhite, Shared.SelectedCard.RemoteHeaderURL, WebImageView.DefaultCircleTransformation); }); }, null); return; } if (requestCode == SelectCompanyLogoPhotoRequestCode) { var imageView = cell.GetCompanyLogoImageView(); imageView.SetImageResource(Resource.Drawable.ic_buildings); imageView.ShowLoadingIndicators(); var localUrl = Shared.SelectedCard.LocalLogoURL; var remoteUrl = Shared.SelectedCard.RemoteLogoURL; var fileName = "Logo.png"; S3Utils.UploadPhoto(bytes, localUrl, remoteUrl, fileName, () => { if (Activity == null) { return; } Activity.RunOnUiThread(async() => { await ImageService.Instance.InvalidateCacheAsync(FFImageLoading.Cache.CacheType.All);//.InvalidateCacheEntryAsync(me.RemoteProfileImageURL, FFImageLoading.Cache.CacheType.All); imageView.SetImage(Shared.SelectedCard.GetRemoteLogoUrlCached(), Resource.Drawable.ic_buildings, Resource.Drawable.ic_buildings, Shared.SelectedCard.RemoteLogoURL, WebImageView.DefaultCircleTransformation); }); }, null); return; } }; } }
public static void BuildContentPacksWithOptions(string distList, bool skipBase, bool uploadProduction = false) { try { var tmpfoler = "/tmp/packs"; GeneralUtils.DeleteDirectory(tmpfoler, true); // mko: cleaning up build folder Directory.CreateDirectory(tmpfoler); var version = "1.0"; try { var parts = PlayerSettings.bundleVersion.Split('.'); version = parts[0] + "." + parts[1]; } catch { } var platform = BuildSettings.Target; var date = System.DateTime.Now.ToString("dd/MM/yy HH:mm"); var cl = EnvironmentUtils.Get("BUILD_CL", "0"); var desc = "Content Package " + BuildSettings.Target + " " + date + " CL: " + cl + "\n"; var notes = (ArrayList)EB.JSON.Parse(EnvironmentUtils.Get("BUILD_NOTES", "[]")); PlayerSettings.bundleVersion = version + "." + cl; // step1 build all the bundles (extended bundles) var options = Bundler.BundleOptions.Force | Bundler.BundleOptions.Extended; if (skipBase) { options |= Bundler.BundleOptions.SkipBase; } var packs = Bundler.BuildAll(BuildSettings.BundlerConfigFolder, options); var files = new ArrayList(); foreach (var pack in packs) { var tarPath = Path.Combine(tmpfoler, pack + ".tar"); var packPath = Path.Combine(BuildSettings.BuildFolder, pack); var gzipPath = tarPath + ".gz"; // turn into gz, tar archive using (var gzFile = new FileStream(gzipPath, FileMode.Create, FileAccess.ReadWrite)) { using (var gzStream = new Ionic.Zlib.GZipStream(gzFile, Ionic.Zlib.CompressionMode.Compress, Ionic.Zlib.CompressionLevel.BestCompression)) { var writer = new tar_cs.TarWriter(gzStream); foreach (var packFile in Directory.GetFiles(packPath, "*", SearchOption.AllDirectories)) { var relativeName = packFile.Substring(packPath.Length + 1); //Debug.Log("file: " + relativeName); using (var f = new FileStream(packFile, FileMode.Open, FileAccess.Read)) { writer.Write(f, f.Length, relativeName, string.Empty, string.Empty, 511, System.DateTime.UtcNow); } } writer.Close(); } } var info = new Hashtable(); var size = new FileInfo(gzipPath).Length; info["size"] = size; info["url"] = S3Utils.Put(gzipPath, Path.Combine(cl, Path.GetFileName(gzipPath))); info["md5"] = S3Utils.CalculateMD5(gzipPath); info["pack"] = pack; info["included"] = skipBase; files.Add(info); } // send email var data = new Hashtable(); data["cl"] = int.Parse(cl); data["minVersion"] = int.Parse(cl); data["title"] = desc; data["notes"] = notes; data["files"] = files; data["platform"] = platform; var manifest = EB.JSON.Stringify(data); var manifestUrl = S3Utils.PutData(EB.Encoding.GetBytes(manifest), "manifest.json", Path.Combine(cl, "manifest.json")); data["manifest"] = manifestUrl; if (!string.IsNullOrEmpty(manifestUrl)) { UploadContentManifest(WWWUtils.Environment.LocalTest, manifestUrl, skipBase ? 1 : 0); if (uploadProduction) { UploadContentManifest(WWWUtils.Environment.LocalTest, manifestUrl, skipBase ? 1 : 0); } } Email(distList, "New " + platform + " Content Build: " + cl, File.ReadAllText("Assets/Editor/EB.Core.Editor/Build/Email/contentbuild.txt"), data); Done(); } catch (System.Exception ex) { Debug.Log("BuildContentPacks Failed: exception: " + ex.ToString()); Failed(ex); } ClearProgressBar(); }
/// <summary> /// Get presign canonical request. /// </summary> /// <param name="requestMethod">HTTP method used for this request</param> /// <param name="uri">Full url for this request, including all query parameters except for headers and X-Amz-Signature</param> /// <param name="headersToSign"></param> /// <returns>Presigned canonical request</returns> internal string GetPresignCanonicalRequest(Method requestMethod, Uri uri, SortedDictionary <string, string> headersToSign) { var canonicalStringList = new LinkedList <string>(); // METHOD canonicalStringList.AddLast(requestMethod.ToString()); string path = uri.AbsolutePath; canonicalStringList.AddLast(path); var queryParams = uri.Query.TrimStart('?').Split('&').ToList(); queryParams.AddRange(headersToSign.Select(cv => $"{Utils.UrlEncode(cv.Key)}={Utils.UrlEncode(S3Utils.TrimAll(cv.Value))}")); queryParams.Sort(StringComparer.Ordinal); string query = string.Join("&", queryParams); canonicalStringList.AddLast(query); var canonicalHost = GetCanonicalHost(uri); canonicalStringList.AddLast($"host:{canonicalHost}"); canonicalStringList.AddLast(string.Empty); canonicalStringList.AddLast("host"); canonicalStringList.AddLast("UNSIGNED-PAYLOAD"); return(string.Join("\n", canonicalStringList)); }
/// <summary> /// 根据数据生成对应的Bundle压缩文件 /// </summary> /// <param name="bundle"></param> /// <returns></returns> private static bool BuildSingleBundle(BundleData bundle) { // Prepare bundle output dictionary string outputPath = GenerateOutputPathForBundle(bundle.name); string bundleStoreDir = Path.GetDirectoryName(outputPath); if (!Directory.Exists(bundleStoreDir)) { Directory.CreateDirectory(bundleStoreDir); } if (File.Exists(outputPath)) { File.Delete(outputPath); } // Start build string[] assetPaths = GetAssetsFromPaths(BundleManager.GUIDsToPaths(bundle.includeGUIDs.ToArray().Concat(bundle.exIncludeGUIDs.ToArray()).ToArray()), bundle.sceneBundle); bool succeed = false; uint crc = 0; if (bundle.sceneBundle) { succeed = BuildSceneBundle(assetPaths, outputPath, out crc); } else { succeed = BuildAssetBundle(assetPaths, outputPath, out crc); } if (succeed /* && !BMDataAccessor.BMConfiger.compress*/) { succeed = CompressBundle(ref outputPath, true); } // Remember the assets for next time build test BundleBuildState buildState = BundleManager.GetBuildStateOfBundle(bundle.name); if (succeed) { buildState.lastBuildDependencies = AssetDatabase.GetDependencies(assetPaths); FileInfo bundleFileInfo = new FileInfo(outputPath); //Only has bundle real change will change version if (buildState.crc != crc || buildState.size != bundleFileInfo.Length) { buildState.version++; buildState.crc = crc; buildState.size = bundleFileInfo.Length; } if (buildState.version == int.MaxValue) { buildState.version = 0; } // refresh depends //BundleManager.RefreshBundleDependencies(bundle); //BMDataAccessor.SaveBundleData(); // fix build state if (buildState.changeTime == -1) { buildState.changeTime = bundleFileInfo.LastWriteTime.ToBinary(); } if (string.IsNullOrEmpty(buildState.bundleName)) { buildState.bundleName = bundle.name; } if (BMDataAccessor.BuildStates.Find(x => x.bundleName == bundle.name) == null) { BMDataAccessor.BuildStates.Add(buildState); } // generate bundle ship info if (BMDataAccessor.BundleShipInfos.Find(item => item.BundleName == bundle.name) == null) { GM.BundleInfo _tmp = new GM.BundleInfo(); _tmp.BundleName = bundle.name; _tmp.Paths = new List <string>(); _tmp.Includes = new List <string>(); BMDataAccessor.BundleShipInfos.Add(_tmp); } GM.BundleInfo _shipinfo = BMDataAccessor.BundleShipInfos.Find(item => item.BundleName == bundle.name); _shipinfo.Paths.Clear(); _shipinfo.Includes.Clear(); foreach (string _i in bundle.includs.ToArray().Concat(bundle.exIncludes.ToArray())) { if (string.IsNullOrEmpty(_i) || string.IsNullOrEmpty(Path.GetExtension(_i))) { _shipinfo.Paths.Add(_i); } else { _shipinfo.Paths.Add(_i.Replace(Path.GetExtension(_i), string.Empty)); } _shipinfo.Includes.Add(Path.GetFileNameWithoutExtension(_i)); } _shipinfo.Parent = bundle.parent.StartsWith("+") ? string.Empty : bundle.parent; _shipinfo.Version = buildState.version; _shipinfo.MD5 = S3Utils.CalculateMD5(System.Text.Encoding.Default.GetBytes(buildState.size.ToString() + buildState.crc.ToString())); _shipinfo.Size = buildState.size; BMDataAccessor.SaveBundleShipInfoFile(); } else { buildState.lastBuildDependencies = null; } BMDataAccessor.SaveBundleBuildeStates(); return(succeed); }
public static void BuildIPA(string distributionList) { try { BuildSettings.IsDevelopmentBuild = _debug; BuildUtils.CleanData(); var folder = BuildSettings.BaseBuildFolder; var platformFolder = BuildSettings.BuildFolder; // moko: changed to do a debug dump of all builder job info first var date = System.DateTime.Now.ToString("dd/MM/yy HH:mm"); string header = "*******************************************************************************\n"; header += "Building to " + folder + " @" + date; EB.Debug.Log(header); EB.Debug.Log("Build Setting Parameters:\n" + BuildSettings.ToString()); EB.Debug.Log("Envirnoment Setting Parameters:\n" + EnvironmentUtils.GetEnvirnomentDetails()); EB.Editor.PostProcess.Signer = _cert.Trim('\''); // clean up old ipa files CommandLineUtils.Run("/bin/rm", "-f *.ipa"); // cleanup GeneralUtils.DeleteDirectory(platformFolder, true); // mko: cleaning up build folder GeneralUtils.DeleteDirectory("iPad", true); // mko: cleaning up build folder Directory.CreateDirectory(folder); Directory.CreateDirectory(platformFolder); Directory.CreateDirectory("iPad"); // always check for null. EditorUserBuildSettings.explicitNullChecks = true; var version = "1.0"; try { var parts = PlayerSettings.bundleVersion.Split('.'); version = parts[0] + "." + parts[1]; } catch { } // moko: prepend #define instead of replace in case there is some specific settings stored in playerSetting string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS); if (_debug) { PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, "USE_DEBUG;" + defines); } var cl = EnvironmentUtils.Get("BUILD_CL", "0"); var desc = "iOS Univeral " + date + " CL: " + cl + "\n"; var notes = (ArrayList)EB.JSON.Parse(EnvironmentUtils.Get("BUILD_NOTES", "[]")); PlayerSettings.bundleVersion = version + "." + cl; PlayerSettings.applicationIdentifier = BuildSettings.BundleIdentifier; PlayerSettings.use32BitDisplayBuffer = true; WriteVersionFile(version + "." + cl); if (!_debug) { PlayerSettings.bundleVersion = BuildSettings.Version; } EB.Debug.Log("Desc: " + desc); // build bundles DisplayProgressBar("Building", "Building Bundles", 0.0f); BuildUtils.CleanData(); if (BuildSettings.DevBundleMode != EB.Assets.DevBundleType.NoBundles) { Bundler.BuildAll(BuildSettings.BundlerConfigFolder, BuildSettings.BundlerOptions | Bundler.BundleOptions.Extended); } else { Bundler.BuildAll(BuildSettings.BundlerConfigFolder, Bundler.BundleOptions.Extended | Bundler.BundleOptions.Force); } // build the player DisplayProgressBar("Building", "Building Player", 0.0f); iOSUtils.BuildiOSPlayer(_profile, _debug, (_debug ? BuildOptions.Development : BuildOptions.None)); DisplayProgressBar("Building", "Building IPA", 0.0f); var ipaFile = Path.Combine(folder, cl + ".ipa"); FileUtil.DeleteFileOrDirectory(ipaFile); iOSUtils.CompileiOSPlayer(_profile, _cert, ipaFile, _debug); // upload to s3 var ipaUrl = S3Utils.Put(ipaFile, string.Format("{0}-{1}-{2}.ipa", PlayerSettings.applicationIdentifier, PlayerSettings.bundleVersion, cl)); var dsymUrl = string.Empty; // upload symbols var zipName = Path.GetFileNameWithoutExtension(ipaFile) + ".dSYM.zip"; var zipDir = Path.GetDirectoryName(ipaFile); var zipFile = Path.Combine(zipDir, zipName); if (File.Exists(zipFile)) { EB.Debug.Log("Adding symbols file"); dsymUrl = S3Utils.Put(zipFile, Path.GetFileName(zipFile)); } var size = new FileInfo(ipaFile).Length; var data = new Hashtable(); data["cl"] = cl; data["size"] = size / (1024.0f * 1024.0f); data["title"] = desc; data["ipaUrl"] = ipaUrl; data["dSymUrl"] = dsymUrl; data["notes"] = notes; Email(distributionList, BuildSettings.ProjectName + " - iOS Submission Build: " + version + "@" + cl, File.ReadAllText("Assets/Editor/EB.Core.Editor/Build/Email/submissionbuild.txt"), data); // build extended packs //BuildContentPacksWithOptions(true); Done(); } catch (System.Exception e) { EB.Debug.Log("Build Failed: exception: " + e.ToString()); Failed(e); } ClearProgressBar(); }
internal static RestRequest CreateRequest(string baseURL, RestSharp.Method method, RestSharp.Authenticators.IAuthenticator authenticator, string bucketName = null, bool secure = false, string objectName = null, Dictionary <string, string> headerMap = null, string contentType = "application/octet-stream", object body = null, string resourcePath = null) { Utils.ValidateBucketName(bucketName); if (objectName != null) { Utils.ValidateObjectName(objectName); } // Start with user specified endpoint string host = baseURL; string resource = string.Empty; bool usePathStyle = false; if (bucketName != null) { if (S3Utils.IsAmazonEndPoint(baseURL)) { if (method == Method.PUT && objectName == null && resourcePath == null) { // use path style for make bucket to workaround "AuthorizationHeaderMalformed" error from s3.amazonaws.com usePathStyle = true; } else if (resourcePath != null && resourcePath.Contains("location")) { // use path style for location query usePathStyle = true; } else if (bucketName != null && bucketName.Contains(".") && secure) { // use path style where '.' in bucketName causes SSL certificate validation error usePathStyle = true; } else if (method == Method.HEAD && secure) { usePathStyle = true; } if (usePathStyle) { resource += Utils.UrlEncode(bucketName) + "/"; } } else { resource += Utils.UrlEncode(bucketName) + "/"; } } if (objectName != null) { resource += Utils.EncodePath(objectName); } // Append query string passed in if (resourcePath != null) { resource += resourcePath; } RestRequest request = new RestRequest(resource, method); if (body != null) { request.AddParameter(contentType, body, RestSharp.ParameterType.RequestBody); } if (headerMap != null) { foreach (var entry in headerMap) { request.AddHeader(entry.Key, entry.Value); } } return(request); }
public async void DownloadFacebookImage(WebImageView imageView, string localUrl, string remoteUrl, string fileName) { if (imageView == null) { return; } var me = RealmUserServices.GetMe(false); if (me == null) { return; } var url = me.GetFacebookProfilePictureUrl(); if (url == null) { return; } imageView.SetImageResource(Resource.Drawable.ic_noprofilewhite); //required to remove it here otherwise itll load form cache await ImageService.Instance.InvalidateCacheEntryAsync(me.RemoteProfileImageURL, FFImageLoading.Cache.CacheType.All, true); ImageService.Instance.LoadUrl(url).Success(async(FFImageLoading.Work.ImageInformation arg1, FFImageLoading.Work.LoadingResult arg2) => { if (arg1 == null) { return; } var image = await ImageUtils.GetImageAtPath(arg1.FilePath); if (image == null) { return; } var bytes = ImageUtils.ImagetoByteArray(image, 100); if (bytes == null) { return; } S3Utils.UploadPhoto(bytes, localUrl, remoteUrl, fileName, () => { if (Activity == null) { return; } Activity.RunOnUiThread(async() => { await ImageService.Instance.InvalidateCacheAsync(FFImageLoading.Cache.CacheType.All);//.InvalidateCacheEntryAsync(me.RemoteProfileImageURL, FFImageLoading.Cache.CacheType.All); imageView.SetImage(me.GetRemoteProfileImageUrlCached(), Resource.Drawable.ic_noprofilewhite, Resource.Drawable.ic_noprofilewhite, me.RemoteProfileImageURL, WebImageView.DefaultCircleTransformation); }); }, null); }) .Finish((FFImageLoading.Work.IScheduledWork obj) => { }) .Transform(WebImageView.DefaultCircleTransformation) .Error(exception => { imageView.ShowLoadingIndicators(); return; }) .Into(imageView); }
void SelectImageFromGallery(ICardView target, string localUrl, string remoteUrl, string fileName,string cacheKey) { if (target == null) return; var vc = new GalleryImagePicker(); vc.Canceled += (sender, e) => { vc.DismissViewController(true, null); }; vc.FinishedPickingMedia += (object sender, UIImagePickerMediaPickedEventArgs e) => { switch (e.Info[UIImagePickerController.MediaType].ToString()) { case "public.image": Console.WriteLine("Image selected"); target.ToggleLoadingIndicators(true); UIImage editedImage = e.Info[UIImagePickerController.EditedImage] as UIImage; editedImage = ImageUtils.ScaledToSize(editedImage, new CGSize(200, 200)); var bytes = ImageUtils.ByteArrayFromImage(editedImage, 100); S3Utils.UploadPhoto(bytes,localUrl, remoteUrl, fileName, () => { SDWebImageManager.SharedManager.ImageCache.ClearDisk(); SDWebImageManager.SharedManager.ImageCache.ClearMemory(); Update(true); }, null); break; case "public.video": Console.WriteLine("Video selected"); break; } vc.DismissViewController(true, null); }; PresentViewController(vc, true, null); }
/// <summary> /// Constructs a RestRequest. For AWS, this function has the side-effect of overriding the baseUrl /// in the RestClient with region specific host path or virtual style path. /// </summary> /// <param name="method">HTTP method</param> /// <param name="bucketName">Bucket Name</param> /// <param name="objectName">Object Name</param> /// <param name="headerMap">headerMap</param> /// <param name="contentType">Content Type</param> /// <param name="body">request body</param> /// <param name="resourcePath">query string</param> /// <returns>A RestRequest</returns> /// <exception cref="BucketNotFoundException">When bucketName is invalid</exception> internal async Task <RestRequest> CreateRequest(Method method, string bucketName = null, string objectName = null, Dictionary <string, string> headerMap = null, string contentType = "application/octet-stream", object body = null, string resourcePath = null) { string region = string.Empty; if (bucketName != null) { Utils.ValidateBucketName(bucketName); region = await GetRegion(bucketName).ConfigureAwait(false); } if (objectName != null) { Utils.ValidateObjectName(objectName); } // Start with user specified endpoint string host = this.BaseUrl; this.restClient.Authenticator = new V4Authenticator(this.Secure, this.AccessKey, this.SecretKey, region: string.IsNullOrEmpty(this.Region)?region:this.Region, sessionToken: this.SessionToken); // This section reconstructs the url with scheme followed by location specific endpoint (s3.region.amazonaws.com) // or Virtual Host styled endpoint (bucketname.s3.region.amazonaws.com) for Amazon requests. string resource = string.Empty; bool usePathStyle = false; if (bucketName != null) { if (S3Utils.IsAmazonEndPoint(this.BaseUrl)) { usePathStyle = false; if (method == Method.PUT && objectName == null && resourcePath == null) { // use path style for make bucket to workaround "AuthorizationHeaderMalformed" error from s3.amazonaws.com usePathStyle = true; } else if (resourcePath != null && resourcePath.Contains("location")) { // use path style for location query usePathStyle = true; } else if (bucketName != null && bucketName.Contains(".") && this.Secure) { // use path style where '.' in bucketName causes SSL certificate validation error usePathStyle = true; } if (usePathStyle) { resource += Utils.UrlEncode(bucketName) + "/"; } } else { resource += Utils.UrlEncode(bucketName) + "/"; } } // Set Target URL Uri requestUrl = RequestUtil.MakeTargetURL(this.BaseUrl, this.Secure, bucketName, region, usePathStyle); SetTargetURL(requestUrl); if (objectName != null) { resource += Utils.EncodePath(objectName); } // Append query string passed in if (resourcePath != null) { resource += resourcePath; } RestRequest request = new RestRequest(resource, method); if (body != null) { request.AddParameter(contentType, body, RestSharp.ParameterType.RequestBody); } if (headerMap != null) { foreach (var entry in headerMap) { request.AddHeader(entry.Key, entry.Value); } } return(request); }
/// <summary> /// A simple function that takes a string and does a ToUpper /// </summary> /// <returns></returns> public async Task <string> FunctionHandler() { var pushOverUser = _configService.GetConfiguration()["PushOverUser"]; //Init Notification to pushover api var po = new Pushover(_configService.GetConfiguration()["PushOverSecret"]); try { //Get items for rss feeds var itemsfeed = GetRssFeeds(); List <Item> items = _mapper.Map <List <Item> >(itemsfeed); //filter items _filteringTerms = _configService.GetConfiguration()["FilteringTerms"].Split(";").ToList(); List <Item> newItems = items.Where(i => _filteringTerms.Any(t => i.Title.ToUpper().Contains(t) || i.Summary.ToUpper().Contains(t))).ToList(); //get file from s3 var client = new S3Utils(); var jobs = await client.GetFileContent(keyName); //Get new items not in db var filteredItems = newItems.Where(item => jobs.All(dbi => dbi.Id != item.Id)) .ToList(); // Quick message: foreach (var newItem in filteredItems) { newItem.CreatedDate = DateTime.Now; var msg = new Message(Sounds.Pushover) { Title = newItem.Id.ToLower().Contains("freelancer") ? $"Freelancer : {newItem.Title}" : $"Upwork : {newItem.Title}", Body = SubStringBody(newItem.Summary), Priority = Priority.Normal, IsHtmlBody = true, Timestamp = DateTime.Now, SupplementaryUrl = new SupplementaryURL { Uri = new Uri(newItem.Link), Title = newItem.Title } }; var sendtask = po.SendMessageAsync(msg, pushOverUser); } //Insert new items in db if (filteredItems.Any()) { try { jobs.AddRange(filteredItems); var lastJobsOnly = jobs.Where(i => i.CreatedDate >= DateTime.Now.AddDays(-7)).ToList(); await client.UploadFile(lastJobsOnly, keyName); } catch (Exception e) { throw e; } } return("ok"); } catch (Exception e) { var msg = new Message(Sounds.Echo) { Title = $"Error {e.InnerException}", Body = SubStringBody(e.Message), Priority = Priority.Emergency, IsHtmlBody = true, Timestamp = DateTime.Now }; var sendtask = po.SendMessageAsync(msg, pushOverUser); throw e; } }
if (cardBack != null) cardBack.BindDataToView(SelectedCard, Editable); PerformFlipAnimationIfNecessary(); } public void PerformFlipAnimationIfNecessary() { var cardFront = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardFront)).First(); var cardBack = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardBack)).First(); //animation not needed if (cardFront.Hidden == SelectedCard.IsFlipped) return; UIView.Transition(View, 0.5, UIViewAnimationOptions.TransitionFlipFromRight, () => { cardFront.Hidden = SelectedCard.IsFlipped; cardBack.Hidden = !SelectedCard.IsFlipped; }, null); } public void Flip() { if (SelectedCard == null) return; SelectedCard.Flip(); var cardFront = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardFront)).First(); var cardBack = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardBack)).First(); UIView.Transition(View, 0.5, UIViewAnimationOptions.TransitionFlipFromRight, () => { cardFront.Hidden = SelectedCard.IsFlipped; cardBack.Hidden = !SelectedCard.IsFlipped; }, null); } void DownloadFacebookImage(ICardView target, string localUrl, string remoteUrl, string fileName, string cacheKey) { if (target == null) return; var me = RealmUserServices.GetMe(false); if (me == null) return; var url = me.GetFacebookProfilePictureUrl(); if (url == null) return; target.ToggleLoadingIndicators(true); SDWebImageManager.SharedManager.ImageDownloader.DownloadImage(NSUrl.FromString(url), SDWebImageDownloaderOptions.HighPriority, null, (image, data, error, finished) => { if (image == null || error != null) { target.ToggleLoadingIndicators(false); return; } var bytes = ImageUtils.ByteArrayFromImage(image, 100); S3Utils.UploadPhoto(bytes, localUrl,remoteUrl, fileName, () => { SDWebImageManager.SharedManager.ImageCache.RemoveImage(cacheKey, true, null); Update(true); }, null); }); }