I need
to send the image file using multipart request from Lightroom to
my local web service using Lua language.
I have
tested using sending headers also but not working...
I have
created a function called as uploadUsingMultipart ():
Calling
this uploadUsingMultipartfunction from:
function
exportServiceProvider.processRenderedPhotos(functionContext,
exportContext)
-- Make a local reference to the export parameters.
local exportSession = exportContext.exportSession
local exportParams = assert(exportContext.propertyTable)
-- Set progress title.
local nPhotos = exportSession:countRenditions()
-- get server
-- serverId = exportParams.serverValue
-- server = prefs.serverTable[serverId].server
-- get album
-- local albumName = exportParams.albumValue
-- outputToLog("album name==" .. albumName)
local progressScope = exportContext:configureProgress {
title = nPhotos > 1
and
LOC("$$$/GalleryUpload/Upload/Progress=Uploading ^1 photos to the
Gallery", nPhotos)
or LOC
"$$$/GalleryUpload/Upload/Progress/_One_=Uploading one photo to the
Gallery",
}
-- Iterate through photo renditions.
local failures = {}
local photos_added = {}
for i, rendition in exportContext:renditions { stopIfCanceled
= true } do
-- update the progress information
progressScope:setPortionComplete((i - 1) / nPhotos)
-- Get next photo.
local photo = rendition.photo
if not rendition.wasSkipped then
local success, pathOrMessage =
rendition:waitForRender()
-- Check for cancellation again after photo has been
rendered.
if progressScope:isCanceled() then
break
end
if success then
local filename =
LrPathUtils.leafName(pathOrMessage)
exportServiceProvider.uploadUsingMultipart(pathOrMessage)
-- When done with photo, delete temp file. There
is a cleanup step that happens later,
-- but this will help manage space in the event of
a large upload.
LrFileUtils.delete(pathOrMessage)
end
end
end
end
function
uploadUsingMultipart(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 = 'multipart/form-data'
}
}
local response, headers = LrHttp.postM
ultipart(url, mycontent)
end
But my
web service is not getting called properly and I am using
LrHttp.postMultipart() method to do so..
If I am
sending just this param to web service (then working fine):
{
name = "lightroom_message",
value = "sent from lightroom plugin multiparta"
}
but when
I include my file payload then its not working using pure Lua
implementation.