0

I have a waffle lua web application and I need to process submitted video file using some command-line tools.

The problem is that a call to save function on req.form.file is asynchronous so execution proceeds before the file is actually saved.

req.form.file:save{path=path}

When I call command line tool ffprobe on that path I get errors indicating invalid data. Using the same command in console works as expected.

My guess is that the file is not yet saved when a call to ffprobe is executed.

Is there a way to ensure the file is written to disk before proceeding with further commands in lua waffle app?

Chandan Rai
  • 9,879
  • 2
  • 20
  • 28
Antonio Simunovic
  • 229
  • 1
  • 2
  • 10

1 Answers1

1

I've found a way to do it, instead of using asynchronous method provided by waffle module, I've used build in lua io module that does the job synchronously:

local out = assert(io.open(path, "wb"))
out:write(req.form.file.data)
Antonio Simunovic
  • 229
  • 1
  • 2
  • 10