Keep Lua tmpfile after execute

840 Views Asked by At

Uploades file represented as tmpfile() and will be removed then script exits. How to hardlink this file to keep its content after removing tmpfile?

How to get name of file by its handle?

> a=io.tmpfile()
> print(a)
file (0x20c8790)
> lfs=require"lfs"
> lfs.link(a,"/tmp/aaaa")
stdin:1: bad argument #1 to 'link' (string expected, got FILE*)
stack traceback:
    [C]: in function 'lfs.link'
    stdin:1: in main chunk
    [C]: in ?

This file is too big to copy it by byte to another.

1

There are 1 best solutions below

0
On

io.tmpfile uses tmpfile of stdio.h, so it wont be possible to adjust this exported function. you can use libraries such as pl.path to get full path of temp file.