When Salesforce is life!

Month: December 2014

[Salesforce / JS] Download automatically files from apex (using href link and base64)

This post is a recap of this Salesforce Developer Forum thread.

We want to trigger a download from an attachment but the running user don’t have access to the object (think of Community User for instance).

In the controller read the Attachment’s body in a String getter coded in Base64:

public String base64Value{get;set;}
public String contentType{get;set;}
public void loadAttachment(){
   Attachment att = [Select Id, Body, ContentType From Attachment limit 1];
   base64Value = EncodingUtil.base64Encode(att.Body);
   contentType = att.ContentType;
}

In the page:

<a href="data:{!contentType};content-disposition:attachment;base64,{!base64Value}">Download file</a>

[Chrome Extension] “Pack your link” extension on the store by enree.co (yes, thet’s me…)

a{ color: red !important;}

I’m not a marketing guy, I neither have requested advices from my marketing guys friends…I did it all my way and that’s why my brand new Chrome Extension will be forgotten in days!

Let’s start from the beginning…

Once upon a time there was a simple Chrome Extension I made at work for WebResults, my Company: you will hear about it in weeks, but not now.

After weeks of testing we decided to put it in the market but I didn’t now how to do it (I know, there si plenty of stuff online, but I don’t trust myself till I see things done!…that’s why because sometimes I behave like Goofy when dealing with simple tasks!!).

So I thought, “How can I do a clean job for my company without making foolish mistakes”?

The answer was “Create your own extension”.

That’s why I created url.enree.co (I love this domain name), a simple Url packing utility hosted on Heroku, written in NodeJS.

Why not creating a simple chrome extension to use this service?

Here you are Pack your link by url.enree.co.

Publishing a Chrome Extension on the store is really easy.

  1. Create your extension (start here if you don’t know what to do, it’s easy and fun)
  2. Go to the Chrome Store Developer dashboard: you have to pay 5$ to be able to publish your creations on the store, once in a lifetime! In few minutes you’ll be allowed to publish extensions and apps.
  3. ZIP your local extension’s folder and upload it: it seems that you cannot remove a product once uploaded (read more details here, but I’m not quite sure about it), but you can still unpublish to hide it.

See ya!

Powered by WordPress & Theme by Anders Norén