Exemple #1
0
        /// <summary>
        /// private helper method to remove list of objects from bucket
        /// </summary>
        /// <param name="args">GetObjectArgs Arguments Object encapsulates information like - bucket name, object name etc </param>
        /// <param name="cancellationToken">Optional cancellation token to cancel the operation</param>
        private async Task <ObjectStat> getObjectHelper(GetObjectArgs args, CancellationToken cancellationToken = default(CancellationToken))
        {
            // StatObject is called to both verify the existence of the object and return it with GetObject.
            // NOTE: This avoids writing the error body to the action stream passed (Do not remove).
            StatObjectArgs statArgs = new StatObjectArgs()
                                      .WithBucket(args.BucketName)
                                      .WithObject(args.ObjectName)
                                      .WithVersionId(args.VersionId)
                                      .WithMatchETag(args.MatchETag)
                                      .WithNotMatchETag(args.NotMatchETag)
                                      .WithModifiedSince(args.ModifiedSince)
                                      .WithUnModifiedSince(args.UnModifiedSince)
                                      .WithServerSideEncryption(args.SSE);

            if (args.OffsetLengthSet)
            {
                statArgs.WithOffsetAndLength(args.ObjectOffset, args.ObjectLength);
            }
            ObjectStat objStat = await this.StatObjectAsync(statArgs, cancellationToken : cancellationToken).ConfigureAwait(false);

            args.Validate();
            if (args.FileName != null)
            {
                await this.getObjectFileAsync(args, objStat, cancellationToken);
            }
            else
            {
                await this.getObjectStreamAsync(args, objStat, args.CallBack, cancellationToken);
            }
            return(objStat);
        }
 internal StatObjectResponse(HttpStatusCode statusCode, string responseContent, Dictionary <string, string> responseHeaders, StatObjectArgs args)
     : base(statusCode, responseContent)
 {
     // StatObjectResponse object is populated with available stats from the response.
     this.ObjectInfo = ObjectStat.FromResponseHeaders(args.ObjectName, responseHeaders);
 }