public override int GetHashCode() { return(AccountID?.GetHashCode() ?? 0 ^ BucketID?.GetHashCode() ?? 0 ^ BucketName?.GetHashCode() ?? 0 ^ BucketType?.GetHashCode() ?? 0 ^ Revision.GetHashCode()); }
public override string ToString() { return(string.Concat(BucketName, BucketName.EndsWith("/") ? string.Empty : "/", Key)); }
protected override void Execute(CodeActivityContext context) { try { var mUniversalDataHandler = new AwsS3DataHandler(AccessKey.Get(context), SecretKey.Get(context), Region.Get(context)); mUniversalDataHandler.CreateDir(Generate(SourcePath.Get(context), BucketName.Get(context))); Response.Set(context, "Complete"); } catch (Exception e) { Error.Set(context, e.Message); } }
public UseAmazon(IOptionsSource optionsSource) { if (optionsSource is null) { throw new ArgumentNullException(nameof(optionsSource)); } var options = optionsSource.AmazonOptions; _client = new Lazy <AmazonS3Client>(GetClient(options.ClientInformation)); _bucketName = options.BucketName; _parallelParts = options.ParallelParts; _initializer = new Lazy <Task>(DoInitialize()); }
void ReleaseDesignerOutlets() { if (AccessKeyID != null) { AccessKeyID.Dispose(); AccessKeyID = null; } if (AccessKeySecret != null) { AccessKeySecret.Dispose(); AccessKeySecret = null; } if (BucketName != null) { BucketName.Dispose(); BucketName = null; } if (Endpoint != null) { Endpoint.Dispose(); Endpoint = null; } if (SaveButton != null) { SaveButton.Dispose(); SaveButton = null; } if (ServiceName != null) { ServiceName.Dispose(); ServiceName = null; } if (ShareCredentialsCell != null) { ShareCredentialsCell.Dispose(); ShareCredentialsCell = null; } if (StoreCredentialsCell != null) { StoreCredentialsCell.Dispose(); StoreCredentialsCell = null; } }
protected override void Execute(CodeActivityContext context) { try { var mUniversalDataHandler = new AzureUniversalDataHandler(AccessKey.Get(context)); mUniversalDataHandler.Copy(Generate(SourcePath.Get(context), BucketName.Get(context)) , Generate(TargetPath.Get(context), BucketName.Get(context))); Response.Set(context, "Complete"); } catch (Exception e) { Error.Set(context, e.Message); } }
public override int GetHashCode() => (BucketName?.GetHashCode() ?? 0) ^ Count.GetHashCode();
private void VerifyCredentials(object sender, EventArgs e) { var name = ServiceName.Text; var invalidCharHit = false; foreach (var character in VirtualFileSystem.InvalidCharacters) { if (name?.Contains(character) == true) { invalidCharHit = true; } } if (string.IsNullOrEmpty(name) || invalidCharHit) { this.ShowAlert(this.Localize("Online.BadName"), this.Localize("Online.IllegalName"), action => { ServiceName.BecomeFirstResponder(); }); return; } var endpoint = Endpoint.Text; if (string.IsNullOrEmpty(endpoint)) { this.ShowAlert(this.Localize("Online.BadCredential"), this.Localize("AliYun.BadEndpoint"), action => { Endpoint.BecomeFirstResponder(); }); return; } var bucket = BucketName.Text; if (string.IsNullOrEmpty(bucket)) { this.ShowAlert(this.Localize("Online.BadCredential"), this.Localize("AliYun.BadBucket"), action => { BucketName.BecomeFirstResponder(); }); return; } var accessId = AccessKeyID.Text; if (string.IsNullOrEmpty(accessId)) { this.ShowAlert(this.Localize("Online.BadCredential"), this.Localize("AliYun.BadUserID"), action => { AccessKeyID.BecomeFirstResponder(); }); return; } var accessSecret = AccessKeySecret.Text; if (string.IsNullOrEmpty(accessSecret)) { this.ShowAlert(this.Localize("Online.BadCredential"), this.Localize("AliYun.BadUserSecret"), action => { AccessKeySecret.BecomeFirstResponder(); }); return; } if (!Globals.Database.IsStorageNameUnique(name)) { this.ShowAlert(this.Localize("Online.ServiceAlreadyExists"), this.Localize("Online.ChooseADifferentName"), action => { ServiceName.BecomeFirstResponder(); }); return; } var alert = UIAlertController.Create(this.Localize("Online.Verifying"), null, UIAlertControllerStyle.Alert); PresentViewController(alert, true, () => { Task.Run(() => { var config = new OssConfig { OssEndpoint = endpoint, BucketName = bucket, AccessKeyId = accessId, AccessKeySecret = accessSecret }; if (config.Verify()) { try { Globals.CloudManager.AddStorageProvider(Globals.CloudManager.PersonalClouds[0].Id, Guid.NewGuid(), name, config, visibility); InvokeOnMainThread(() => { DismissViewController(true, () => { NavigationController.DismissViewController(true, null); }); }); } catch { InvokeOnMainThread(() => { DismissViewController(true, () => { this.ShowAlert(this.Localize("AliYun.CannotAddService"), this.Localize("Error.Internal")); }); }); } } else { InvokeOnMainThread(() => { DismissViewController(true, () => { this.ShowAlert(this.Localize("Error.Authentication"), this.Localize("AliYun.Unauthorized")); }); }); } }); }); }
public bool Equals(S3BucketKeyInfo other) { return(other != null && BucketName.Equals(other.BucketName, StringComparison.OrdinalIgnoreCase) && Key.Equals(other.Key, StringComparison.OrdinalIgnoreCase)); }
public int Executar(string nomeDoArquivo, MemoryStream arquivo) { var bucketName = BucketName.RandomName(); var outputPrefix = ""; var gcsSourceURI = $"gs://{bucketName}/{nomeDoArquivo}"; SortedDictionary <string, SortedSet <string> > _garbage = new SortedDictionary <string, SortedSet <string> >(); StorageClient _storage = StorageClient.Create(); _storage.CreateBucket(_projectId, bucketName); _storage.UploadObject(bucketName, nomeDoArquivo, "application/pdf", arquivo); SortedSet <string> objectNames; if (!_garbage.TryGetValue(bucketName, out objectNames)) { objectNames = _garbage[bucketName] = new SortedSet <string>(); } objectNames.Add(nomeDoArquivo); var client = ImageAnnotatorClient.Create(); var asyncRequest = new AsyncAnnotateFileRequest { InputConfig = new InputConfig { GcsSource = new GcsSource { Uri = gcsSourceURI }, MimeType = "application/pdf" }, OutputConfig = new OutputConfig { // How many pages should be grouped into each json output file. BatchSize = 100, GcsDestination = new GcsDestination { Uri = $"gs://{bucketName}/{outputPrefix}" } } }; asyncRequest.Features.Add(new Feature { Type = Feature.Types.Type.DocumentTextDetection }); List <AsyncAnnotateFileRequest> requests = new List <AsyncAnnotateFileRequest> { asyncRequest }; var operation = client.AsyncBatchAnnotateFiles(requests); operation.PollUntilCompleted(); var blobList = _storage.ListObjects(bucketName, outputPrefix); var output = blobList.Where(x => x.Name.Contains(".json")).First(); var jsonString = ""; using (var stream = new MemoryStream()) { _storage.DownloadObject(output, stream); jsonString = System.Text.Encoding.UTF8.GetString(stream.ToArray()); } var response = JsonParser.Default.Parse <AnnotateFileResponse>(jsonString); int total = 0; for (int i = 0; i < response.Responses.Count; i++) { var pageResponses = response.Responses[i]; if (pageResponses != null) { var annotation = pageResponses.FullTextAnnotation; var conteudo = annotation.Text.Replace("\n", " "); var remocaoDosEspacos = conteudo.Split(' '); foreach (var item in remocaoDosEspacos) { total += item.Length; } } } RemoverArquivos(bucketName); return(total); }
private void VerifyCredentials(object sender, EventArgs e) { var name = ServiceName.Text; var invalidCharHit = false; foreach (var character in PathConsts.InvalidCharacters) { #pragma warning disable CA1307 // Specify StringComparison if (name?.Contains(character) == true) { invalidCharHit = true; } #pragma warning restore CA1307 // Specify StringComparison } if (string.IsNullOrEmpty(name) || invalidCharHit) { this.ShowWarning(this.Localize("Online.BadName"), this.Localize("Online.IllegalName"), () => { ServiceName.BecomeFirstResponder(); }); return; } var endpoint = Endpoint.Text; if (string.IsNullOrEmpty(endpoint)) { this.ShowWarning(this.Localize("Online.BadCredential"), this.Localize("AliYun.BadEndpoint"), () => { Endpoint.BecomeFirstResponder(); }); return; } var bucket = BucketName.Text; if (string.IsNullOrEmpty(bucket)) { this.ShowWarning(this.Localize("Online.BadCredential"), this.Localize("AliYun.BadBucket"), () => { BucketName.BecomeFirstResponder(); }); return; } var accessId = AccessKeyID.Text; if (string.IsNullOrEmpty(accessId)) { this.ShowWarning(this.Localize("Online.BadCredential"), this.Localize("AliYun.BadUserID"), () => { AccessKeyID.BecomeFirstResponder(); }); return; } var accessSecret = AccessKeySecret.Text; if (string.IsNullOrEmpty(accessSecret)) { this.ShowWarning(this.Localize("Online.BadCredential"), this.Localize("AliYun.BadUserSecret"), () => { AccessKeySecret.BecomeFirstResponder(); }); return; } if (!Globals.Database.IsStorageNameUnique(name)) { this.ShowWarning(this.Localize("Online.ServiceAlreadyExists"), this.Localize("Online.ChooseADifferentName"), () => { ServiceName.BecomeFirstResponder(); }); return; } var hud = MBProgressHUD.ShowHUD(NavigationController.View, true); hud.Label.Text = this.Localize("Online.Verifying"); Task.Run(() => { var config = new OssConfig { OssEndpoint = endpoint, BucketName = bucket, AccessKeyId = accessId, AccessKeySecret = accessSecret }; if (config.Verify()) { try { Globals.CloudManager.AddStorageProvider(Globals.CloudManager.PersonalClouds[0].Id, Guid.NewGuid(), name, config, visibility); InvokeOnMainThread(() => { hud.Hide(true); NavigationController.DismissViewController(true, null); }); } catch { InvokeOnMainThread(() => { hud.Hide(true); this.ShowError(this.Localize("AliYun.CannotAddService"), this.Localize("Error.Internal")); }); } } else { InvokeOnMainThread(() => { hud.Hide(true); this.ShowError(this.Localize("Error.Authentication"), this.Localize("AliYun.Unauthorized")); }); } }); }
public override int GetHashCode() { return(BucketName.GetHashCode() + ObjectName.GetHashCode()); }