【发布时间】:2016-04-09 07:28:22
【问题描述】:
我需要使用来自 Lightroom 的多部分请求将图像文件发送到使用 Lua 语言的本地 Web 服务。
我也测试过使用发送标头但不工作...
我已经创建了一个函数:
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)
结束
但是我的网络服务没有被正确调用,我正在使用 LrHttp.postMultipart() 方法来这样做..
如果我只是将这个参数发送到网络服务(然后工作正常):
{
name = "lightroom_message",
value = "sent from lightroom plugin multiparta"
}
但是当我包含我的文件有效负载时,它无法使用纯 Lua 实现。
【问题讨论】:
-
这不是有效的 Lua 代码。尝试
function testupload() .... end而不是function testupload(){ ... } -
@moteus 我知道并且我已经编辑了它......但只是想知道为什么 postMultipart 不起作用......以及我的表(mycontent)中有什么问题,它是我的发帖请求
-
“没有正确调用”是什么意思?你在哪里定义文件路径?
-
@Piglet 我在函数 testupload 中传递文件路径