如何在Lua中使用LrHttp.posMultipart上传文件
我需要使用多部分请求将图像文件从Lightroom发送到使用Lua语言的本地web服务 我也使用发送头进行了测试,但不起作用 我创建了一个函数:如何在Lua中使用LrHttp.posMultipart上传文件,lua,lua-table,Lua,Lua Table,我需要使用多部分请求将图像文件从Lightroom发送到使用Lua语言的本地web服务 我也使用发送头进行了测试,但不起作用 我创建了一个函数: function testupload(filepath) --created inside LrTasks local url = "http://localhosturl" local mycontent = { { name = "lightroom_message",
function testupload(filepath) --created inside LrTasks
local url = "http://localhosturl"
local mycontent = {
{
name = "lightroom_message",
value = "sent from lightroom plugin multiparta"
},
{
name = 'file',
filePath = filepath,
fileName = LrPathUtils.leafName(filepath),
contentType = 'image/jpeg'
--contentType = 'multipart/form-data'
}
}
local response, headers = LrHttp.postMultipart(url, mycontent)
结束
但是我的web服务没有被正确调用,我正在使用LrHttp.postMultipart()方法来实现这一点
如果我只是将此参数发送到web服务(然后工作正常):
但是当我包含我的文件负载时,它不能使用纯Lua实现。一切都是正确的,但只是一个技术错误…我试图从LRtasks内部调用testupload()函数。但是我们不需要在单独的任务中调用它,函数工作正常。这不是有效的Lua代码。尝试函数testupload()。。。。结束而不是
函数testupload(){…}
@moteus我知道并且我已经编辑了它…但是我只想知道为什么postMultipart不工作…以及我的表(mycontent)有什么问题,这是我的帖子请求的主体。你说的“没有正确调用”是什么意思您在哪里定义了filepath?@piege我在函数testupload中传递文件的路径
{
name = "lightroom_message",
value = "sent from lightroom plugin multiparta"
}