Hi, I am trying to submit a “multipart/form-data” using this:
https://raw.githubusercontent.com/benglard/Augment/master/App/class_MultipartFormData.lua
I did get response from the server but the image file seems not able to upload or something wrong. When I tried to download my uploaded image, it shows a blank image only.
The following is my code:
local MultipartFormData = require("class\_MultipartFormData") local multipart = MultipartFormData.new() multipart:addHeader("Content-Type", "multipart/form-data") multipart:addField("acl",fields['acl']) multipart:addField("Content-Type",fields['Content-Type']) multipart:addField("key",fields['key']) multipart:addField("AWSAccessKeyId",fields['AWSAccessKeyId']) multipart:addField("policy",fields['policy']) multipart:addField("signature",fields['signature']) multipart:addFile("file", system.pathForFile( "profile\_pic.jpg", system.TemporaryDirectory ), fields['Content-Type'], "profile\_pic.jpg") local params = {} params.body = multipart:getBody() params.headers = multipart:getHeaders() network.request( baseUrl, "POST", networkListener, params)
Anyone can help? I don’t have any control on the server side. I need to upload an image file in temp folder with some fields data for validation with the given API call.