Logic Machine Forum
Sending images package to app - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Sending images package to app (/showthread.php?tid=1433)



Sending images package to app - buuuudzik - 08.06.2018

Hello,

could you add some example how i can integrate in custom app importing and exporting a package with images?

I know how to upload and download file(there is such example on this forum) so it is more about dealing with files on LM (read/create .zip, saving multiple files)


RE: Sending images package to app - admin - 15.06.2018

There are no built-in functions for handling archives. You have to use shell commands via os.execute to create/read archives.
You can also try doing this in browser via JSZip: https://stuk.github.io/jszip/


RE: Sending images package to app - equalizer - 01.04.2020

(15.06.2018, 08:11)admin Wrote: There are no built-in functions for handling archives. You have to use shell commands via os.execute to create/read archives.
You can also try doing this in browser via JSZip: https://stuk.github.io/jszip/
Hi.

Im getting a bunch (2~10) of (Small 0.1~2Kb)  .xml files sent to a SpaceLynk via FTP.  Unfortunately they are arriving all lumped into a zip file.  Is there an example for the os.execute zip open command to open it?.

I'm pretty confident of being able to deal with the .xml files once I have them.  :-)


RE: Sending images package to app - admin - 01.04.2020

Use this example to extract files from zip and read them:
Code:
zip = '/home/ftp/files.zip' -- source zip archive

if not io.exists(zip) then
  alert('file not found')
  return
end

dir = '/tmp/zip'
os.execute('rm -rf ' .. dir) -- clean-up
os.execute('mkdir ' .. dir) -- create dir
os.execute('unzip -qq -j "' .. zip .. '" -d ' .. dir) -- unzip

files = io.ls(dir) -- list file
for _, file in ipairs(files) do
  data = io.readfile(dir .. '/' .. file)
  log(file, data)
end

os.execute('rm -rf ' .. dir) -- clean-up