lua lfs on flashair w04 seems not to work

283 Views Asked by At

Hi for the last week i have been trying to get my Flashair to upload its files over ftp.

I can make a ftp connection without any problems, but when i try to iterate over the files in its folder its gives me a error on the lua lfs, the only thing its returning is nil.

its goes about this code sample:

for file in lfs.dir(localDir) do
attr = lfs.attributes(localDir .. file)
print( "Found "..attr.mode..": " .. file )
  if attr.mode == "file" then
    response = fa.ftp("put", ftpString..file, localDir .. file)
    if response ~= nil then
        print("Success!")
    else
        print("Fail!")
    end
  end
end

the error i get is:

lua: ftp.lua:17: attempt to index a nil value (global 'lfs') stack traceback: ftp.lua:17: in main chunk [C]: in ?

where line 17 is the first line in the provided code sample.

Am I missing something, seems that i cannot find a lot information about this problem in combination with the Flashair.

Any help would be appreciated.

1

There are 1 best solutions below

1
On

I am new to Lua so don't flame me if my response is not beneficial to you. I have been developing an app for W-03 and when testing the Lua app on my MACBOOK linux virtual env I was seeing the same error, and discovered I had to use require "lfs" statement in my test code. require "lfs" is not necessary when running on the actual W-03 though.