Merge remote-tracking branch 'origin/netcore/feature/contentcontroller_and_related' into netcore/feature/remaining-backoffice-controllers

This commit is contained in:
Bjarke Berg
2020-06-26 09:49:03 +02:00
4 changed files with 19 additions and 12 deletions

View File

@@ -20,11 +20,11 @@ namespace Umbraco.Configuration.Models
{
new ImagingAutoFillUploadField
{
Alias = "umbracoFile",
WidthFieldAlias = "umbracoWidth",
HeightFieldAlias ="umbracoHeight",
ExtensionFieldAlias = "umbracoExtension",
LengthFieldAlias = "umbracoBytes"
Alias = Constants.Conventions.Media.File,
WidthFieldAlias = Constants.Conventions.Media.Width,
HeightFieldAlias =Constants.Conventions.Media.Height,
ExtensionFieldAlias =Constants.Conventions.Media.Extension,
LengthFieldAlias =Constants.Conventions.Media.Bytes,
}
};

View File

@@ -112,16 +112,16 @@ namespace Umbraco.Web.Media
if (content == null) throw new ArgumentNullException(nameof(content));
if (autoFillConfig == null) throw new ArgumentNullException(nameof(autoFillConfig));
if (!(autoFillConfig.WidthFieldAlias is null) && content.Properties.Contains(autoFillConfig.WidthFieldAlias))
if (!string.IsNullOrEmpty(autoFillConfig.WidthFieldAlias) && content.Properties.Contains(autoFillConfig.WidthFieldAlias))
content.Properties[autoFillConfig.WidthFieldAlias].SetValue(size.HasValue ? size.Value.Width.ToInvariantString() : string.Empty, culture, segment);
if (!(autoFillConfig.HeightFieldAlias is null) && content.Properties.Contains(autoFillConfig.HeightFieldAlias))
if (!string.IsNullOrEmpty(autoFillConfig.HeightFieldAlias) && content.Properties.Contains(autoFillConfig.HeightFieldAlias))
content.Properties[autoFillConfig.HeightFieldAlias].SetValue(size.HasValue ? size.Value.Height.ToInvariantString() : string.Empty, culture, segment);
if (!(autoFillConfig.LengthFieldAlias is null) && content.Properties.Contains(autoFillConfig.LengthFieldAlias))
if (!string.IsNullOrEmpty(autoFillConfig.LengthFieldAlias) && content.Properties.Contains(autoFillConfig.LengthFieldAlias))
content.Properties[autoFillConfig.LengthFieldAlias].SetValue(length, culture, segment);
if (!(autoFillConfig.ExtensionFieldAlias is null) && content.Properties.Contains(autoFillConfig.ExtensionFieldAlias))
if (!string.IsNullOrEmpty(autoFillConfig.ExtensionFieldAlias) && content.Properties.Contains(autoFillConfig.ExtensionFieldAlias))
content.Properties[autoFillConfig.ExtensionFieldAlias].SetValue(extension, culture, segment);
}

View File

@@ -23,7 +23,7 @@ namespace Umbraco.Web.BackOffice.ModelBinders
/// normal json formatter will not figure this out.
/// This would also let you bind sub levels of the JSON being sent up too if you wanted with any jsonpath
/// </remarks>
internal class FromJsonPathAttribute : ModelBinderAttribute
public class FromJsonPathAttribute : ModelBinderAttribute
{
public FromJsonPathAttribute() : base(typeof(JsonPathBinder))
{
@@ -40,7 +40,7 @@ namespace Umbraco.Web.BackOffice.ModelBinders
}
var strJson = bindingContext.HttpContext.Request.GetRawBodyString();
var strJson = await bindingContext.HttpContext.Request.GetRawBodyStringAsync();
if (string.IsNullOrWhiteSpace(strJson))

View File

@@ -66,10 +66,17 @@ namespace Umbraco.Extensions
var result = reader.ReadToEnd();
request.Body.Seek(0, SeekOrigin.Begin);
return result;
}
public static async Task<string> GetRawBodyStringAsync(this HttpRequest request, Encoding encoding = null)
{
request.Body.Seek(0, SeekOrigin.Begin);
var reader = new StreamReader(request.Body, encoding ?? Encoding.UTF8);
var result = await reader.ReadToEndAsync();
request.Body.Seek(0, SeekOrigin.Begin);
return result;
}
}
}