Results 1 to 2 of 2

Thread: [SOLVED] Get base64-encoded Attachment file using Javascript?

  1. #1
    ploeger's Avatar
    ploeger is offline Senior Member
    Join Date
    Oct 2008
    Posts
    73
    Rep Power
    6

    Question [SOLVED] Get base64-encoded Attachment file using Javascript?

    Hi!

    I've been looking all over the place, but I can't seem to find it:

    Is it somehow possible, to get the base64-encoded-version of an attachment in JavaScript. I want to write a Zimlet, in which I have to send the attachment binary safe to another web service...

    Thanks in advance!

    Kind regards
    Dennis
    Release 8.0.6.GA.5922.UBUNTU12.64 UBUNTU12_64 NETWORK edition.

  2. #2
    ploeger's Avatar
    ploeger is offline Senior Member
    Join Date
    Oct 2008
    Posts
    73
    Rep Power
    6

    Post

    I solved it by writing a JSP to do that.

    I adopted the Alfresco-JSP for that (for the basics) and used the nice open source base64-encoder/decoder for Java by Christian d'Heureuse located here

    Base64Coder - an open-source Base64 encoder/decoder in Java

    I've zipped both the jsp and the jar-file together and attached it for other people in my position.

    You just need to call the jsp with the parameter messageUrl and set that one to the download-link you get by executing getAttachmentLinks on a message Object like this:

    Code:
    var jspUrl = this.getResource("attachmentToBase64.jsp")+"?messageUrl="+AjxStringUtil.urlComponentEncode(attachment.url);
                    
    var response = AjxRpc.invoke(null, jspUrl, null, null, true, null);
    Always urlComponentEncode the URL!!!

    Kind regards
    Dennis
    Attached Files Attached Files
    Last edited by ploeger; 06-24-2010 at 03:42 AM. Reason: Forgot the attachment
    Release 8.0.6.GA.5922.UBUNTU12.64 UBUNTU12_64 NETWORK edition.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. File attachment size modification
    By warcries in forum Installation
    Replies: 1
    Last Post: 06-17-2010, 01:59 AM
  2. ZCS from perforce on OpenSuSE 11
    By asemenov in forum Developers
    Replies: 0
    Last Post: 06-09-2010, 03:13 AM
  3. Replies: 1
    Last Post: 01-14-2010, 04:03 AM
  4. File attachment / associations
    By bert_w in forum Administrators
    Replies: 4
    Last Post: 02-03-2009, 07:11 AM
  5. M3 problem with shares
    By titangears in forum Users
    Replies: 4
    Last Post: 01-12-2006, 01:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •