Hi,
I have the source code for DasBlog and I also have the source code for a patch I need to implement in DasBlog.
Problem is I'm NOT a programmer and I don't have a clue where to start.
Here is the patch with some instructions:
---
metaWeblog.newMediaObject
Hi.
Don't know where to post this patch.
I use dasBlog, and I was trying to create a post with
an image using an external software with the
metaWeblog API.
As for uploading an image you can only use the method
newMediaObject, and as it doesn't exist on the last
version of dasBlog, I'd quickly made one.
So, here's my code, working with the first try I made.
(For a better view I deleted comments)
On the project "newtelligence.DasBlog.Web.Services",
in the file "MetaWeblog.cs", added the code in the
namespace :
public struct MediaType
{
public string name;
public string type;
public byte[] bits;
}
In the IMetaWeblog interface, added :
[XmlRpcMethod("metaWeblog.newMediaObject",
Description="Upload a new file to the binary
content. Returns url as a string")]
string metaweblog_newMediaObject (string
blogid, string username, string password, MediaType
enc);
Then, on the file BloggerAPI.cs in the "BloggerAPI"
class, added the code :
string IMetaWeblog.metaweblog_newMediaObject(string
blogid, string username, string password, MediaType
enc)
{
if ( !siteConfig.EnableBloggerApi )
{
throw new ServiceDisabledException();
}
UserToken token = SiteSecurity.Login
(username, password);
if (token == null)
{
throw new
System.Security.SecurityException();
}
string strPath =
SiteConfig.GetBinariesPathFromCurrentContext() +
enc.name;
FileStream fs = new FileStream(strPath,
FileMode.CreateNew);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(enc.bits);
bw.Close();
fs.Close();
return siteConfig.BinariesDirRelative +
enc.name;
}
As I use a BinaryWriter, you have to add the
System.IO reference.
Hope it's ok,
Xas.
---
Cansomeone tell me the easiest way to get this incorporated into DasBlog?
Thanks!
I have the source code for DasBlog and I also have the source code for a patch I need to implement in DasBlog.
Problem is I'm NOT a programmer and I don't have a clue where to start.
Here is the patch with some instructions:
---
metaWeblog.newMediaObject
Hi.
Don't know where to post this patch.
I use dasBlog, and I was trying to create a post with
an image using an external software with the
metaWeblog API.
As for uploading an image you can only use the method
newMediaObject, and as it doesn't exist on the last
version of dasBlog, I'd quickly made one.
So, here's my code, working with the first try I made.
(For a better view I deleted comments)
On the project "newtelligence.DasBlog.Web.Services",
in the file "MetaWeblog.cs", added the code in the
namespace :
public struct MediaType
{
public string name;
public string type;
public byte[] bits;
}
In the IMetaWeblog interface, added :
[XmlRpcMethod("metaWeblog.newMediaObject",
Description="Upload a new file to the binary
content. Returns url as a string")]
string metaweblog_newMediaObject (string
blogid, string username, string password, MediaType
enc);
Then, on the file BloggerAPI.cs in the "BloggerAPI"
class, added the code :
string IMetaWeblog.metaweblog_newMediaObject(string
blogid, string username, string password, MediaType
enc)
{
if ( !siteConfig.EnableBloggerApi )
{
throw new ServiceDisabledException();
}
UserToken token = SiteSecurity.Login
(username, password);
if (token == null)
{
throw new
System.Security.SecurityException();
}
string strPath =
SiteConfig.GetBinariesPathFromCurrentContext() +
enc.name;
FileStream fs = new FileStream(strPath,
FileMode.CreateNew);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(enc.bits);
bw.Close();
fs.Close();
return siteConfig.BinariesDirRelative +
enc.name;
}
As I use a BinaryWriter, you have to add the
System.IO reference.
Hope it's ok,
Xas.
---
Cansomeone tell me the easiest way to get this incorporated into DasBlog?
Thanks!