Entries Tagged as 'Coldfusion'

Creating zip file from URL list in ColdFusion

For one of our client had requirement to download photos in zip format and it was working file with cfzip tag. Although I have some performance issue with cfzip tag as cfzip doesn’t allow you to zip with list of files. We can create zip for whole folder, add single file but can’t have ability to add list of files at single instance. In my case I have around 50 images which I need to add into zip file and I have only one way to do so is adding one by one file. I was looking for alternative solution for creating zip which gives faster performance with adding file list.

Now here is different story, recently we have decided to move our archived photos on cloud server because of billions of images causing disk space issue. We have two kinds of photos in our application, one is on our file server and physically accessible so easy to add into zip file using cfzip and other on cloud server which give us URL to access those photos. Only way for me to add into zip that download files from cloud and store on application server and add into zip. I already have performance issue with cfzip for photos stored in same server and downloading photos make it much slower. Finally I have decided to build custom code using java zip library.

After googling I found coldfusion code which let you create zip file using java zip library (thanks to Artur Kordowski)which let me add files in zip by file list but again it will not let you add file from URL. I use cfhttp to retrieve image from cloud which return ByteArrayOutputStream object which can be added easily into zip code component.  Below is fully functional code to add file from URL to zip component.

<cfset zipFilePath = expandPath('./test.zip') />
<cfset images = "http://t2.gstatic.com/images?q=tbn:_ruOuQ2EjL3wOM:http://www.flash-slideshow-maker.com/images/help_clip_image020.jpg,http://t0.gstatic.com/images?q=tbn:--IQZoA0t4jdOM:http://www.dynamicdrive.com/dynamicindex4/lightbox2/flower.jpg,http://t3.gstatic.com/images?q=tbn:7i1D2KAZcCd8yM:http://www.flash-slideshow-maker.com/images/help_clip_image004.jpg" />
<cfscript>
    /* Create Objects */
    ioOutput    = CreateObject("java","java.io.FileOutputStream");
    zipFile     = CreateObject("java","java.util.zip.ZipFile");
    zipEntry    = CreateObject("java","java.util.zip.ZipEntry");
    zipInput    = CreateObject("java","java.util.zip.ZipInputStream");
    zipOutput   = CreateObject("java","java.util.zip.ZipOutputStream");
    
    ioOutput.init(zipFilePath);
    zipOutput.init(ioOutput);
    zipOutput.setLevel(9);
</cfscript> 
<cfloop list="#images#" index="uri">
    <cfset filename= listlast(uri,"/") />
    <cfhttp url="#uri#" method="get">
    <cfset objByteIO = cfhttp.filecontent />
    <cfscript>
        flag = true;
        path = uri;
        entryFile = filename;
        
        //  Skip if entry with the same name already exsits
        try
        {
            zipEntry.init(entryFile);
            zipOutput.putNextEntry(zipEntry);
            objByteIO.toByteArray();
            zipOutput.write(objByteIO.toByteArray(), 0, objByteIO.size());
            zipOutput.closeEntry();
        }
        catch(java.util.zip.ZipException ex)
        { skip = "yes"; }
    </cfscript> 
</cfloop>


<cfscript>zipOutput.close();</cfscript>

NOTE: Above code will work only when cfhttp returns ByteArrayOutputStream, in other case you may need to modify as per need.

How to declare argument's attributes in cfscript function

Hello Friends,
All persons are familiar with cfscript function would like to know how to define parameters qualifiers in cfscript function.
It is just FYI on how to define arguments qualifiers i.e. default value of parameter, It's datatype, Required Or Not. I hope you may find it interesting.

Syntax

    
    public function fun_name(required string argument1 = ''){}

Generally, Using <cfargument /> tag we may declare something like this.

    <cfargument name="arg1" default="123" required="true" type="numeric">


CfScript Equivalent:
    public function scriptFunction(required numeric arg1 = 123){
        .....
    }    

You need to take care about sequence of argument. It will take default required = 'false'. Click here to know more...

ColdFusion wrapper for jQuery autocomplete.

For one of my project I required autocomplete box. I know coldfusion has its own autocomplete but has lots of limitation. I wanted autocomplete to work like select box of html, display lable of product in list but in backend it will return ID for that product and as usual I just stop at jQuery-ui Autocomplete (I just love jquery) which allow good customization.
This coldfusion wrapper allow you to use jqury autocomplete with coldfusion query variables or loading data remotely.

Example:

<cf_autocomplete
textFieldName="productName" textFieldValue="" textFieldBind="PRODUCTNAME"
idFieldName="productId" idFieldBind = "PRODUCTID"
datasource="/cfc/products.cfc?method=getActiveProduct&returnFormat=JSON"
fieldList="PRODUCTID,PRODUCTNAME,PRICE"
queryParam="product" 
displayTemplate="<div><img src=""/images/{PRODUCTID}.gif"">{PRODUCTNAME}&nbsp;: {PRICE}" 
minlength=2 />

Read more...

CFPresentation

One of the tags introduced in ColdFusion 8 is CFPRESENTATION, which allows you to create a Flash-based presentation that is very slick and can take full advantage of many ColdFusion tools.

In my opinion, it's best not to think of this as a PowerPoint alternative. Instead, it's a slick way to create online (or offline) presentations where you want to include live content or render slides in a customizable manner.

Please refer below example. 



<cfpresentation title="iSummation Technology LTD">
    <cfpresenter name="Naresh"
        biography="Naresh is a skilled software developer.">
    <cfpresentationslide title="Introduction"
        presenter="Naresh"
        duration="30">
        We are a Software development and IT outsourcing company based in India. 
        We have worked for over 10 years in custom web & desktop software development..
        We work primarily on DotNet & ColdFusion platforms for software development. 
        Our services include application development & maintenance related activities 
        for a whole spectrum of applications like ERP software, management software, 
        ecommerce systems, legacy systems etc. 
    </cfpresentationslide>
    <cfpresentationslide title="Services"
        presenter="Naresh"
        duration="10" >
        •    Content Management System (CMS) <br >
        •    EDocument Management System ( DMS) <br>
        •    Knowledge Management System (KMS) <br>
        •    Custom web based application development <br>
        •    Coldfusion, .Net , Ajax programming / Programmer services <br>
    </cfpresentationslide>


</cfpresentation>

 

DEMO

ColdFusion And AJAX File Upload

Hello All,

I have created simple jquery plugin for file upload.
I have used multiple file upload in Ajax but it’s not possible to upload file in Ajax.
This problem can be solved by this two method.

  1. flash to solve this problem.
  2. JavaScript works.

Javascript works more nice than Flash.

Read more...

Promote and support coldfusion on web - All CFers must have a look at this.

Hello all,

Yesterday i was just googling around and found very generous approach which can help CF community  to grow and expand as much as it can. If anybody has their CF powered website they can register too in this community. I urge all CFers to atleast visit GOT CFM and try to promote CF worldwide.

One more thing i found about coldfusion and the excerpt says :

Who's using coldfusion?

 'More than 770,000 developers at over 12,000 companies worldwide rely on Adobe® ColdFusion® software to rapidly build and deploy Internet applications. And with more than 125,000 ColdFusion servers deployed, ColdFusion is one of the most widely adopted web technologies in the industry.'

 

wrap text in cfgrid - cf9

Hi ,

We have been updated to cf9 from cf8 and we noticed that text in cfgrid column in not wrapped. Its just because of changes made in version 3 of ext. Turns out the fix is pretty simple. Look at the css code below which has to be applied on a page where you require to wrap text in cfgrid.

CF8:

<style>
.x-grid-row-selected td{color:black;}
.x-grid-col{white-space: normal ! important;}
.x-grid-cell-text {white-space: normal !important;}
</style>

CF9:

<style>
.x-grid3-cell-inner {white-space: normal ! important; display:block;}
</style>

 

Install SSL certificate in coldfusion.

Hello Guys,

Before couple of days, we migrated from coldfusion 8 to coldfusion 9. One of our project was using web services to transmit some updates on another application. It seems something wrong since upgradation.  The error which was repeatedly occured was 'javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated'. It occurs when you use self signed SSL certificate. To get rid of this you have to add the certificate to the list of known certs.

Please perform following steps to do so.

  • Then open a command prompt and go to coldfusion jre/bin directory.



$ cd /opt/jrun/jre/bin


  • You can install a new certificate by following command.



./keytool -import -storepass changeit -noprompt -alias newcertificate  -keystore ../lib/security/cacerts -trustcacerts -file newcertificate.cer


  1. alias - You can give any name alias to this.
  2. storepass is the password for the security store.If you haven't changed it it will be set to 'changeit'.
  3. file - certificate file which you need to install.

Make sure you have read, write permission to that certificate file.

After sucessfully following above points you still get an error then please restart you coldfusion services. I hope this would help you.

 

Design by Mark Aplet | Powered by Mango Blog