コード例 #1
0
        private HttpResult put <Entity>(ContentDto request, string type) where Entity : Metadata, new()
        {
            var entity = Db.Select <Entity>(e => e.OwnerId == GetCurrentAuthUserId() && e.Id == request.Id)
                         .FirstOrDefault();

            if (entity != null)
            {
                var objectKey = $"{GetCurrentAuthUserId()}-{type}-{entity.Id}";
                var S3Object  = new S3ObjectMetadata(Environment.GetEnvironmentVariable("S3_BUCKET_NAME"), objectKey);

                S3Object.upStreamThroughLocalBuffer(request.RequestStream);

                entity.IsUploaded = true;
                Db.Save(entity);

                return(new HttpResult(HttpStatusCode.OK, "Ok"));
            }
            else
            {
                return(new HttpResult(HttpStatusCode.BadRequest, "Resource does not exist or you are not its owner"));
            }
        }
コード例 #2
0
        private void populateWithId(ContentDto dto)
        {
            var segments = base.Request.PathInfo.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            dto.Id = int.Parse(segments[3]);
        }