This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Sending images package to app
#1
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)
Done is better than perfect
Reply
#2
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/
Reply
#3
(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.  :-)
Reply
#4
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
Reply


Forum Jump: