I've uploaded a zip file with ffmpeg for lambda. I've run a ls -l
command to verify the ffmpeg
utility is there and it was (no permissions though).
To have it run I understand that i need to copy it to /tmp
folder and changed the permissions there. I've tried to do this with:
/bin/sh -c echo 'step0' && cp /var/task/ffmpeg /tmp && echo 'step1' && chmod 755 /tmp/ffmpeg && echo 'step2' && ls /tmp/
but all I see is the step0
in the output of the test lambda functionality.
It seems that the copy command fails somehow.
NB: I'm using a java lambda but I don't see how this can make a difference at this level because the lambda call and command seems to pass through.
Many thanks.
UPDATE:
public class Lambda implements RequestHandler<FragmentsRequest, String> {
@Override
public String handleRequest(final FragmentsRequest input, final Context context) {
final List<String> command = Stream.of(input.getCommand().split(",")).collect(Collectors.toList());
final String output = runCommandForOutput(command);
return output;
}
public static String runCommandForOutput(List<String> params) {
final ProcessBuilder pb = new ProcessBuilder(params);
Process p;
String result = "";
try {
p = pb.start();
final BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
final StringJoiner sj = new StringJoiner(System.getProperty("line.separator"));
reader.lines().iterator().forEachRemaining(sj::add);
result = sj.toString();
p.waitFor();
p.destroy();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}