private GetObjectTaggingCommand(IServiceClient client, Uri endpoint, ExecutionContext context, IDeserializer <ServiceResponse, GetObjectTaggingResult> deserializer, GetObjectTaggingRequest request) : base(client, endpoint, context, deserializer) { _request = request; }
static void ReadObjectTags() { string id = Common.InputString("Key:", null, false); int ver = Common.InputInteger("Version:", 1, true, false); try { GetObjectTaggingRequest request = new GetObjectTaggingRequest(); request.BucketName = _Bucket; request.Key = id; request.VersionId = ver.ToString(); GetObjectTaggingResponse response = _S3Client.GetObjectTaggingAsync(request).Result; if (response != null) { Console.WriteLine("Success"); foreach (Tag curr in response.Tagging) { Console.WriteLine(" " + curr.Key + ": " + curr.Value); } } else { Console.WriteLine("Failed"); } } catch (Exception) { throw new IOException("Unable to read object tags."); } }
public static GetObjectTaggingCommand Create(IServiceClient client, Uri endpoint, ExecutionContext context, GetObjectTaggingRequest request) { OssUtils.CheckBucketName(request.BucketName); OssUtils.CheckObjectKey(request.Key); return(new GetObjectTaggingCommand(client, endpoint, context, DeserializerFactory.GetFactory().CreateGetObjectTaggingResultDeserializer(), request)); }
public async Task <GetObjectTaggingResponse> GetObjectTaggingAsync(string bucketName, string key) { var request = new GetObjectTaggingRequest() { BucketName = bucketName, Key = key }; return(await _s3Client .GetObjectTaggingAsync(request)); }
private async Task <IDictionary <string, string> > ListTagsAsync(string key) { GetObjectTaggingRequest request = new GetObjectTaggingRequest { BucketName = this.BucketName, Key = key }; var response = await this.Client.GetObjectTaggingAsync(request); return(response.Tagging.ToDictionary(x => x.Key, x => x.Value)); }
private async Task <IDictionary <string, string> > GetTagsAsync(S3FileKey key) { var getTagsRequest = new GetObjectTaggingRequest { BucketName = BucketNameConstructor.GetBucketName(key), Key = key.Key, VersionId = key.VersionId }; var objectTags = await AmazonS3.GetObjectTaggingAsync(getTagsRequest); return(objectTags.Tagging.ToDictionary()); }
/// <summary> /// /// <para>GetFileTags:</para> /// /// <para>Gets the tags of the file from the file service</para> /// /// <para>Check <seealso cref="IBFileServiceInterface.GetFileTags"/> for detailed documentation</para> /// /// </summary> public bool GetFileTags( string _BucketName, string _KeyInBucket, out List <Tuple <string, string> > _Tags, Action <string> _ErrorMessageAction = null) { _Tags = new List <Tuple <string, string> >(); if (S3Client == null) { _ErrorMessageAction?.Invoke("BFileServiceAWS->GetFileTags: S3Client is null."); return(false); } GetObjectTaggingRequest TaggingRequest = new GetObjectTaggingRequest { BucketName = _BucketName, Key = _KeyInBucket }; try { using (var CreatedTask = S3Client.GetObjectTaggingAsync(TaggingRequest)) { CreatedTask.Wait(); var TaggingResponse = CreatedTask.Result; if (TaggingResponse == null || TaggingResponse.Tagging == null) { _ErrorMessageAction?.Invoke("BFileServiceAWS->GetFileTags: TaggingResponse or TaggingResponse.Tagging is null."); return(false); } foreach (var CurrentTag in TaggingResponse.Tagging) { if (CurrentTag != null) { _Tags.Add(new Tuple <string, string>(CurrentTag.Key, CurrentTag.Value)); } } } } catch (Exception e) { _ErrorMessageAction?.Invoke("BFileServiceAWS->GetFileTags: " + e.Message + ", Trace: " + e.StackTrace); return(false); } return(true); }
public async Task Execute() { var tagRequest = new GetObjectTaggingRequest() { BucketName = _settings.Bucket, Key = Filename }; var result = await _client.GetObjectTaggingAsync(tagRequest); LogHelper.Log(LogLevel.INFO, "Retrieving tags - DONE. Tags:"); foreach (var tag in result.Tagging) { LogHelper.Log(LogLevel.INFO, $"\tKey: {tag.Key}, Value: {tag.Value}"); } }
public async Task <Dictionary <string, string> > GetTags(string key) { var getTagsRequest = new GetObjectTaggingRequest() { BucketName = BUCKET_NAME, Key = key }; var response = await _s3Client.GetObjectTaggingAsync(getTagsRequest); var result = new Dictionary <string, string>(); foreach (var tag in response.Tagging) { result.Add(tag.Key, tag.Value); } return(result); }
public void GetObjectTagging() { GetObjectTaggingRequest tagRequest = new GetObjectTaggingRequest { BucketName = strBucketName, Key = strObjectName }; GetObjectTaggingResponse objectTags = client.GetObjectTagging(tagRequest); if (objectTags.Tagging.Count == 0) { Console.WriteLine("No Tags Found"); } foreach (var tag in objectTags.Tagging) { Console.WriteLine($"Key: {tag.Key}, Value: {tag.Value}"); } }
private async Task <string> gets3tag(IAmazonS3 s3Client, string id, string newkey) { GetObjectTaggingRequest getTagsRequest = new GetObjectTaggingRequest(); getTagsRequest.BucketName = bucketName; getTagsRequest.Key = id; GetObjectTaggingResponse objectTags = await s3Client.GetObjectTaggingAsync(getTagsRequest); Tag tag = objectTags.Tagging.Find(t => t.Key == "Status"); if (tag != null) { return(tag.Value); } else { return(null); } }
//bucketa gelen dosyaları ayırt etme //olayı kim koydu bu dosyayı public void GetObjectTagging() { GetObjectTaggingRequest request = new GetObjectTaggingRequest { BucketName = bucketName, Key = "test.txt", }; GetObjectTaggingResponse response = client.GetObjectTagging(request); if (response.Tagging.Count == 0) { Console.WriteLine("tags are not found"); } foreach (var tag in response.Tagging) { Console.WriteLine($"Key:{tag.Key}, Values: {tag.Value}"); } Console.ReadLine(); }
public void GetObjectTagging() { GetObjectTaggingRequest tagRequest = new GetObjectTaggingRequest { BucketName = bucketName, Key = "test.txt" }; GetObjectTaggingResponse objectTags = client.GetObjectTagging(tagRequest); if (objectTags.Tagging.Count > 0) { foreach (var tag in objectTags.Tagging) { Console.WriteLine($"Key: {tag.Key} \n Value: {tag.Value}"); } } else { Console.WriteLine("\nNo Tags Found!\n"); } }
private static async Task <CopyObjectResponse> Copy(string sourceBucket, string sourceKey, string destinationBucket, string prefixPattern, ILambdaContext context) { // The S3 key prefixes are separated with a forward slash string[] Parts = sourceKey.Split("/"); string DestinationKey = String.Format(prefixPattern, Parts); string DestinationUri = $"s3://{destinationBucket}/{DestinationKey}"; context.LogInfo($"Using destination: {DestinationUri}"); GetObjectTaggingRequest TagRequest = new GetObjectTaggingRequest() { BucketName = sourceBucket, Key = sourceKey }; GetObjectTaggingResponse TagResponse = await _S3Client.GetObjectTaggingAsync(TagRequest); CopyObjectRequest CopyRequest = new CopyObjectRequest() { DestinationBucket = destinationBucket, SourceBucket = sourceBucket, SourceKey = sourceKey, DestinationKey = DestinationKey, TagSet = TagResponse.Tagging }; CopyObjectResponse Response = await _S3Client.CopyOrMoveObjectAsync(CopyRequest, true); if (Response.HttpStatusCode == HttpStatusCode.OK) { context.LogInfo($"Successfully moved s3://{sourceBucket}/{sourceKey} to {DestinationUri}."); } else { context.LogError($"Unsuccessful copy of s3://{sourceBucket}/{sourceKey} to {DestinationUri} : ${(int)Response.HttpStatusCode}"); } return(Response); }
private async Task <Dictionary <string, string> > GetFileTags(string key) { using (var scope = _logger.BeginScope(nameof(GetFileTags))) { var request = new GetObjectTaggingRequest { BucketName = _s3BucketName, Key = key }; var response = await _s3Client.GetObjectTaggingAsync(request); _logger.LogDebug($"Returned: {JsonConvert.SerializeObject(response)} "); if (response.HttpStatusCode != HttpStatusCode.OK) { return(new Dictionary <string, string>()); } var result = response.Tagging.OrderByDescending(t => t.Value).ToDictionary(t => t.Key, t => t.Value); return(result); } }
public void GetObjectTagging(GetObjectTaggingRequest request, Callback.OnSuccessCallback <CosResult> successCallback, Callback.OnFailedCallback failCallback) { Schedue(request, new GetObjectTaggingResult(), successCallback, failCallback); }
public GetObjectTaggingResult GetObjectTagging(GetObjectTaggingRequest request) { return((Model.Object.GetObjectTaggingResult)Excute(request, new Model.Object.GetObjectTaggingResult())); }
public Task <GetObjectTaggingResponse> GetObjectTaggingAsync(GetObjectTaggingRequest request, CancellationToken cancellationToken = default) { throw new NotImplementedException(); }
static async Task PutObjectWithTagsTestAsync() { try { // 1. Put an object with tags. var putRequest = new PutObjectRequest { BucketName = bucketName, Key = keyName, FilePath = filePath, TagSet = new List <Tag> { new Tag { Key = "Keyx1", Value = "Value1" }, new Tag { Key = "Keyx2", Value = "Value2" } } }; PutObjectResponse response = await client.PutObjectAsync(putRequest); // 2. Retrieve the object's tags. GetObjectTaggingRequest getTagsRequest = new GetObjectTaggingRequest { BucketName = bucketName, Key = keyName }; GetObjectTaggingResponse objectTags = await client.GetObjectTaggingAsync(getTagsRequest); for (int i = 0; i < objectTags.Tagging.Count; i++) { Console.WriteLine("Key: {0}, Value: {1}", objectTags.Tagging[i].Key, objectTags.Tagging[i].Value); } // 3. Replace the tagset. Tagging newTagSet = new Tagging(); newTagSet.TagSet = new List <Tag> { new Tag { Key = "Key3", Value = "Value3" }, new Tag { Key = "Key4", Value = "Value4" } }; PutObjectTaggingRequest putObjTagsRequest = new PutObjectTaggingRequest() { BucketName = bucketName, Key = keyName, Tagging = newTagSet }; PutObjectTaggingResponse response2 = await client.PutObjectTaggingAsync(putObjTagsRequest); // 4. Retrieve the object's tags. GetObjectTaggingRequest getTagsRequest2 = new GetObjectTaggingRequest(); getTagsRequest2.BucketName = bucketName; getTagsRequest2.Key = keyName; GetObjectTaggingResponse objectTags2 = await client.GetObjectTaggingAsync(getTagsRequest2); for (int i = 0; i < objectTags2.Tagging.Count; i++) { Console.WriteLine("Key: {0}, Value: {1}", objectTags2.Tagging[i].Key, objectTags2.Tagging[i].Value); } } catch (AmazonS3Exception e) { Console.WriteLine( "Error encountered ***. Message:'{0}' when writing an object" , e.Message); } catch (Exception e) { Console.WriteLine( "Encountered an error. Message:'{0}' when writing an object" , e.Message); } }
public void GetObjectTaggingAsync(GetObjectTaggingRequest request, AmazonServiceCallback <GetObjectTaggingRequest, GetObjectTaggingResponse> callback, AsyncOptions options = null) { throw new System.NotImplementedException(); }