Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Handling gz-ed tar files in CF?

Enthusiast ,
Feb 09, 2011 Feb 09, 2011

I'm having problems dealing with files that I am receiving that are gzed tar files.  CFZIP does not handle gz files, but I have tried using a function that I found a while back on fusion coder.com that uses java's ability to handle gziped files.  I uses this code to handle the unzipping:

// Open the compressed file
  localStruct.inFilename = "#arguments.inputFilePath#";
  localStruct.file_in = createobject('java','java.io.FileInputStream').init(localStruct.inFilename);
  localStruct.fin_obj = createobject('java','java.util.zip.GZIPInputStream');
  localStruct.fin = localStruct.fin_obj.init(localStruct.file_in);

But my problem is that this gives me the .tar file, and I cannot find any way of pulling the file out of the tar file.

I used to have success doing a CFEXECUTE of the 7z utility, and it seems to automatically ahndle the tar file because all I give it is the .gz file and it sends me back the actual data file that is inside of the tar.  But I'm setting up a new CF server and having problems getting that kludge to work, and am hoping to find a cleaner way of doing all of this.

Any hints are appreciated.  I've been googling this all over but have not found anything that helps me do this from my CF code.  I'm running CF9 btw.

thanks,

-reed

1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 09, 2011 Feb 09, 2011

Did you try this: http://www.trustice.com/java/tar/

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 09, 2011 Feb 09, 2011

Hi Adam - yes, I saw that when I was googling for ideas, but was not able to see how to incorporate it into my CF code.  I'm a CF guy for a real long time, but not too good with the Java side of things.  Both parts of what I need to do (how to get their code in the CF installation, and how to make the actual java calls) are not clear to me.

thanks,

-reed

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 09, 2011 Feb 09, 2011

I had a quick look and the structure seems very similar to what you are  using now. Just pass your .tar file into a TarArchive. Then use  extractContents to extract the files into a directory.

For installation, I downloaded version 2.5. Then copied the jars/tar.jar file into {cf_root}/web-inf/lib/ and restarted.


// because the forum s/w hates html tags
[cfscript]
   // source .tar file
   input = createObject("java", "java.io.FileInputStream").init("c:/pack.tar");
   archive = createObject("java", "com.ice.tar.TarArchive").init(input);
   // extract contents to this directory
   extractToDir = createObject("java", "java.io.File").init("c:/mytar/");
   archive.extractContents(extractToDir);
   archive.closeArchive();
   input.close();
   WriteOutput("Done");
[/cfscript]

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 09, 2011 Feb 09, 2011

Looks like apache has a version too (possibly related) http://commons.apache.org/compress/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 10, 2011 Feb 10, 2011
LATEST

I had a quick look and the structure seems very similar to what you are using now. Just pass your .tar file into a TarArchive. Then use extractContents to extract the files into a directory.

For installation, I downloaded version 2.5. Then copied the jars/tar.jar file into /web-inf/lib/ and restarted.

// because the forum s/w hates html tags

// source .tar file

input = createObject("java", "java.io.FileInputStream").init("c:/pack.tar");

archive = createObject("java", "com.ice.tar.TarArchive").init(input);

// extract contents to this directory

extractToDir = createObject("java", "java.io.File").init("c:/mytar/");

archive.extractContents(extractToDir);

archive.closeArchive();

input.close();

WriteOutput("Done");

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources