base64 encoding of wiki attachment

Forums for specific tips, techniques and example code
javaguy
Posts: 2
Joined: Fri Jul 17, 2009 10:39 am

base64 encoding of wiki attachment

Postby javaguy » Fri Jul 17, 2009 10:47 am

Greetings,
I'm writing a class called MoinMoinProxy to allow programmatic access to the internal wiki using XMLRPC. It works for getting and putting pages, but I'm stuck on uploading an attachment.

Here's an example of the XML I need to generate to send to the MoinMoin server:

<name>params</name>
<value><array><data>
<value><string>AbcPage</string></value>
<value><string>dontpanic.png</string></value>
<value><base64>
iVBORw0KGgoAAAANSUhEUgAAAHgAAABaCAMAAAEz2VJLAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ
zZzUud94FKRIEb5N2+d+6/9A9U8uWj090n8A2xrpEjyby7UAAAAASUVORK5CYII=
</base64></value>
</data></array></value>

How do I load an arbitrary file (png, jpg, pdf, ...) in JADE and convert it to base64?

Thanks.
David

User avatar
BeeJay
Posts: 311
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: base64 encoding of wiki attachment

Postby BeeJay » Fri Jul 17, 2009 11:22 am

Java Guy,

If you have a copy of CardSchema, the CnSmtpConnection class two methods that you could look at:

CnSmtpConnection::base64Encode
CnSmtpConnection::base64Decode

The CnLdapAttribute class also appears to have an implementation of Base64 encoding and decoding as well:

CnLdapAttribute::cnBase64Encode
CnLdapAttribute::cnBase64Decode

Finally, there also appears to be some Base64 encoding/decoding external methods available in karma.dll. The external method versions may well have been implemented for improved performance when encoding larger elements:

emBase64Encode(pMessage: Binary input): String is "emBase64Encode" in "karma" updating, number = 1060;
emBase64Decode(pMessage: String input; pDecodedMessage: Binary output): Integer is "emBase64Decode" in "karma" updating, number = 1059;

I've not used any of them myself other than by way of sending Base64 enconded e-mail messages and attachments, for which it seems to work well, so it may suit your requirements.

Cheers,
BeeJay.

User avatar
jadeloveslave
Posts: 4
Joined: Wed Jun 24, 2009 7:20 am

Re: base64 encoding of wiki attachment

Postby jadeloveslave » Mon Jul 20, 2009 9:58 pm

If you are happy to use unpublished methods (i.e unsupported) then there are the following available for #JADE6.2.15

String::base64Decode
Binary::base64Encode
Binary::base64EncodeNoCrLf

There is current a new feature suggestion open with the JADE plant (#40324) to publish these methods.

regards,
JLS

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: base64 encoding of wiki attachment

Postby ConvertFromOldNGs » Fri Aug 14, 2009 9:52 am

Bump. (To make this message "more recent" than the historical messages converted from the old NNTP Newsgroups.)

johna
Posts: 4
Joined: Fri Jun 19, 2009 9:45 am

Re: base64 encoding of wiki attachment

Postby johna » Sat Aug 15, 2009 8:35 am

I can vouch for the karma ones on both Windows and Linux.


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 5 guests

cron