Uncompress my files in a folder within DocumentsDirectory

Hi,

I have a zip folder on the network . My need is to download and uncompress the same in a subfolder within  DocumentsDirectory. I have achieved the first part , But i am unable to uncompress the files within  the same folder. This is what I havetried :

new_folder_path = lfs.currentdir(system.DocumentsDirectory) … “/MyNewFolder”

    local options = {

            zipFile = event.response.filename,

            zipBaseDir = event.response.baseDirectory,

            dstBaseDir = new_folder_path,

            listener = zipListener,

         }      

         zip.uncompress( options)

Can some one please guide me uncompress the files to MyNewFolder

Please note I am creating MyNewFolder before this code.

Thank you

As far as I know lfs.currentdir() takes no arguments so it just returns the current working directory which you must have set before with lfs.chdir. The rest should be fine.

If you make your dir with lfs you should already be in DocumentsDirectory. Otherwise use

local succes = lfs.chdir(system.pathForFile( “”, system.DocumentsDirectory )

If that does not work try passing the relative path to the zip

dstBaseDir = system.DocumentsDirectory… “/MyNewFolder”

As far as I know lfs.currentdir() takes no arguments so it just returns the current working directory which you must have set before with lfs.chdir. The rest should be fine.

If you make your dir with lfs you should already be in DocumentsDirectory. Otherwise use

local succes = lfs.chdir(system.pathForFile( “”, system.DocumentsDirectory )

If that does not work try passing the relative path to the zip

dstBaseDir = system.DocumentsDirectory… “/MyNewFolder”

Same problem here. Were you able to unzip the files to a subfolder inside DocumentsDirectory?

Zip with subdirectory = unzip into same subdirectory. Old DOS trick. Good luck.

Same problem here. Were you able to unzip the files to a subfolder inside DocumentsDirectory?

Zip with subdirectory = unzip into same subdirectory. Old DOS trick. Good luck.

I had a similar problem. I had to decompress the zip file containing a folders with files.

If you don’t specify the files table for the zip.uncompress() options table it works fine for all the archives without folders.

BUT if you  want to decompress a zip file containing a folder then you have to specify the files table with all the files for zip.uncompress() options table. 

Here is the code that works for unzipping the folders using zip plugin

local zip = require 'plugin.zip' local zipFileName = 'zippedFolder.zip' local function unzipListener( event ) print('unzipping complete') end local unzipOptions = { zipFile = event.response.fileName, zipBaseDir = system.TemporaryDirectory, dstBaseDir = system.DocumentsDirectory, files = {}, listener = unzipListener } local function listZipListener( event ) local fileList = {} for i,v in ipairs(event.response) do fileList[#fileList+1] = v.file end unzipOptions.files = fileList print('zip listing complete') zip.uncompress( unzipOptions ) end local listZipOptions = { zipFile = zipFileName, zipBaseDir = system.TemporaryDirectory, listener = listZipListener } zip.list( listZipOptions )

I had a similar problem. I had to decompress the zip file containing a folders with files.

If you don’t specify the files table for the zip.uncompress() options table it works fine for all the archives without folders.

BUT if you  want to decompress a zip file containing a folder then you have to specify the files table with all the files for zip.uncompress() options table. 

Here is the code that works for unzipping the folders using zip plugin

local zip = require 'plugin.zip' local zipFileName = 'zippedFolder.zip' local function unzipListener( event ) print('unzipping complete') end local unzipOptions = { zipFile = event.response.fileName, zipBaseDir = system.TemporaryDirectory, dstBaseDir = system.DocumentsDirectory, files = {}, listener = unzipListener } local function listZipListener( event ) local fileList = {} for i,v in ipairs(event.response) do fileList[#fileList+1] = v.file end unzipOptions.files = fileList print('zip listing complete') zip.uncompress( unzipOptions ) end local listZipOptions = { zipFile = zipFileName, zipBaseDir = system.TemporaryDirectory, listener = listZipListener } zip.list( listZipOptions )