Ejemplo n.º 1
0
        public Task <FluidValue> ProcessAsync(FluidValue input, FilterArguments arguments, TemplateContext ctx)
        {
            var url      = input.ToStringValue();
            var imageUrl = _mediaFileStore.GetPublicUrl(url);

            return(Task.FromResult <FluidValue>(new StringValue(imageUrl ?? url)));
        }
Ejemplo n.º 2
0
        private async Task <XRpcStruct> MetaWeblogNewMediaObjectAsync(string userName, string password, XRpcStruct file)
        {
            var user = await ValidateUserAsync(userName, password);

            var name = file.Optional <string>("name");
            var bits = file.Optional <byte[]>("bits");

            string directoryName = Path.GetDirectoryName(name);
            string filePath      = _mediaFileStore.Combine(directoryName, Path.GetFileName(name));
            bool   saved         = await _mediaFileStore.TrySaveStreamAsync(filePath, new MemoryStream(bits));

            string publicUrl = _mediaFileStore.GetPublicUrl(filePath);

            return(new XRpcStruct() // Some clients require all optional attributes to be declared Wordpress responds in this way as well.
                   .Set("file", publicUrl)
                   .Set("url", publicUrl)
                   .Set("type", file.Optional <string>("type")));
        }