mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#18414: Fixing BloggerPlus support in XmlRpc
Work Item: 18414 --HG-- branch : 1.x
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Orchard.Core.XmlRpc.Models;
|
using Orchard.Core.XmlRpc.Models;
|
||||||
@@ -29,8 +31,10 @@ namespace Orchard.Core.XmlRpc.Controllers {
|
|||||||
if (methodResponse == null)
|
if (methodResponse == null)
|
||||||
throw new HttpException(500, "TODO: xmlrpc fault");
|
throw new HttpException(500, "TODO: xmlrpc fault");
|
||||||
|
|
||||||
var content = _writer.MapMethodResponse(methodResponse).ToString();
|
var content = new StringBuilder();
|
||||||
return Content(content, "text/xml");
|
_writer.MapMethodResponse(methodResponse).Save(new StringWriter(content));
|
||||||
|
|
||||||
|
return Content(content.ToString(), "text/xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
private XRpcMethodResponse Dispatch(XRpcMethodCall request) {
|
private XRpcMethodResponse Dispatch(XRpcMethodCall request) {
|
||||||
|
|||||||
@@ -65,8 +65,13 @@ namespace Orchard.Media.Services {
|
|||||||
var name = file.Optional<string>("name");
|
var name = file.Optional<string>("name");
|
||||||
var bits = file.Optional<byte[]>("bits");
|
var bits = file.Optional<byte[]>("bits");
|
||||||
|
|
||||||
|
string directoryName = Path.GetDirectoryName(name);
|
||||||
|
if (string.IsNullOrWhiteSpace(directoryName)) { // Some clients only pass in a name path that does not contain a directory component.
|
||||||
|
directoryName = "media";
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// delete the file if it already exists, e.g. and updated image in a blog post
|
// delete the file if it already exists, e.g. an updated image in a blog post
|
||||||
// it's safe to delete the file as each content item gets a specific folder
|
// it's safe to delete the file as each content item gets a specific folder
|
||||||
_mediaService.DeleteFile(Path.GetDirectoryName(name), Path.GetFileName(name));
|
_mediaService.DeleteFile(Path.GetDirectoryName(name), Path.GetFileName(name));
|
||||||
}
|
}
|
||||||
@@ -74,8 +79,11 @@ namespace Orchard.Media.Services {
|
|||||||
// current way to delete a file if it exists
|
// current way to delete a file if it exists
|
||||||
}
|
}
|
||||||
|
|
||||||
string publicUrl = _mediaService.UploadMediaFile(Path.GetDirectoryName(name), Path.GetFileName(name), bits, false);
|
string publicUrl = _mediaService.UploadMediaFile(directoryName, Path.GetFileName(name), bits, true);
|
||||||
return new XRpcStruct().Set("url", url.MakeAbsolute(publicUrl));
|
return new XRpcStruct() // Some clients require all optional attributes to be declared Wordpress responds in this way as well.
|
||||||
|
.Set("file", publicUrl)
|
||||||
|
.Set("url", url.MakeAbsolute(publicUrl))
|
||||||
|
.Set("type", file.Optional<string>("type"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user