private async Task PostBuckets(S3Context ctx) { if (ctx.Http.Request.Url.Elements.Length != 2) { await ctx.Response.Send(S3ServerInterface.S3Objects.ErrorCode.InvalidRequest); return; } byte[] data = null; Bucket bucket = null; try { data = Common.StreamToBytes(ctx.Request.Data); bucket = Common.DeserializeJson <Bucket>(data); } catch (Exception) { await ctx.Response.Send(S3ServerInterface.S3Objects.ErrorCode.InvalidRequest); return; } Bucket tempBucket = _Config.GetBucketByName(bucket.Name); if (tempBucket != null) { await ctx.Response.Send(S3ServerInterface.S3Objects.ErrorCode.BucketAlreadyExists); return; } _Buckets.Add(bucket); ctx.Response.StatusCode = 201; ctx.Response.ContentType = "text/plain"; await ctx.Response.Send(); }