Reputation: 1014
On a daily basis I am download a GZ file that I will then need to decompress and import the contents into my database table.
I found CFX_Gzip.dll from Adobe Coldfusion Exchange. Anyone know where i put the DLL file? It might go in the CF8/lib/ folder, but i'm not sure.
I'm using Coldfusion8. If there is another gzip decompressor that i should use, i'd be delighted if there is one that is more recent. This one is old and the website from the person that wrote it is gone now. No documentation with it.
Upvotes: 2
Views: 1273
Reputation: 6956
Possibly not the most elegant solution, but seems to work for my simple test cases:
<cfscript>
inputFile = "/tmp/test.txt.gz";
outputFile = "/tmp/test.txt";
ioInput = CreateObject("java","java.io.FileInputStream");
gzInput = CreateObject("java","java.util.zip.GZIPInputStream");
ioOutput = CreateObject("java","java.io.FileOutputStream");
ioInput.init(inputFile);
gzInput.init(ioInput);
ioOutput.init(outputFile);
line = 0;
buffer = RepeatString(" ", 1024).getBytes();
while (line GTE 0) {
ioOutput.write(buffer, 0, line);
line = gzInput.read(buffer);
}
gzInput.close();
ioInput.close();
ioOutput.close();
</cfscript>
Upvotes: 1
Reputation: 698
No need of a dll with CF8, use existing java library. Have a look at CFLib or try the following code:
<cfscript>
try{
/* Set inoutput */
gzFileName = "myFile.gz";
outputFile = "mygzFiles";
/* Initialize gzip */
var outStream = CreateObject("java","java.io.FileOutputStream");
var inStream = CreateObject("java","java.io.FileInputStream");
var inGzipStream = CreateObject("java","java.util.zip.GZIPInputStream");
outStream.init(outputFile);
inStream.init(arguments.gzipFilePath);
inGzipStream.init(instance.ioInput);
while(l GTE 0){
outStream.write(buffer, 0, l);
l = inGzipStream.read(buffer);
}
/* Close the GZip file */
inGzipStream.close();
inStream.close();
outStream.ioOutput.close();
} catch(Any){}
</cfscript>
Upvotes: 6
Reputation: 28873
You can use a bit of java to process gzip files http://www.cflib.org/udf/gzip
Upvotes: 1