从 URL 下载文件并保存到 Ubuntu 中

我想从 URL 下载 mp3 文件并将其保存到一个文件夹中。

以下是我的代码:

local sound = HTTPS.request('https://hozory.com/translate/?target='..matches[1]..'&text='..text)

local voice = json:decode(sound)

if voice.result.Voice_link ~= "false" then
local f = assert(io.open('test.mp3', 'w'))
f:write(voice.result.Voice_link)
f:close()

但这会创建一个空的 mp3 文件。

点赞