This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
A web application I am working on stores files on AmazonS3 and I give the user the option of downloading a handful of files at once. These files are pulled down from AS3 then I zip them up before shipping them off to the user. This is a grails app so m code is in Groovy but it's just the Zip API so should be close enough for help here.
I download the files (which include directories of their own) into an initial drop spot. Something like:
And then the system creates a user directory and a timestamp directory so I end up with this..
You get the idea. The problem is that when I zip this up, the zip file contains /applications/... all the way to the actual files. I really need to start at 2010, although it won't always say 2010. So basically, I need to chop off /applications/thehighbar/attachments/board/1234/102343254354/ so they don't get zipped into the zip file. Here's my code..
loopFile is a File object that represents everything from /applications/ up to where 2010 starts. I then loop over all the directories and files within that structure. But since the File has an absolute path starting with /applications/ those still get zipped up as part of the structure. I realize this is kind of confusing. I hope it makes enough sense.