Hi !
I’m trying to do an “instagram” similar post upload with picture,caption,etc in my app. To accomplish this i’m using multi-part form in corona . My image within the post is encoded in base64 as corona doesnt allows uploading of multiple image with attributes in 1 “single post” unless they are base64 encoded(Please correct me if i’m wrong on this).
My problem is when i upload images of a higher resolution , i’ll encounter http error as it seems theres a maximum length to sending the base64 encoded image. Low resolution image is of no problem. This is a big problem for me as image quality are rising(instagram is using 640x640 for their images) and 4k display is on the rise now. I would definitely need to store high quality image. Yet at the same time i must do base64 encoding due to the multi-part form constraint.
Would any of the staffs or experts be able to offer me any advise on this?
This is my upload code, (with credits to Brill Pappin, Sixgreen Labs Inc) https://github.com/GlitchGames/GGTwitter/blob/master/multipartForm.lua
local MultipartFormData = require("class\_MultipartFormData") local multipart = MultipartFormData.new() multipart:addHeader("Authorization", "c4vFdAazaLMi5ivnIWB1XAA2RoIB0mbk1Aut6kgl") multipart:addField("start\_date","2014-10-15") multipart:addField("title","Really Good Title") multipart:addField("end\_date","2014-10-28") multipart:addField("original\_price","10") multipart:addField("duice\_price","5") multipart:addField("category","3") multipart:addField("description","Really good description") multipart:addFile("images[]", system.pathForFile( "uploadingImage.jpg", system.TemporaryDirectory ), "image/jpeg", "uploadingImage.jpg") multipart:addField("quantity","20") local params = {} params.body = multipart:getBody() -- Must call getBody() first! params.headers = multipart:getHeaders() -- Headers not valid until getBody() is called. -- Tell network.request() that we want the "began" and "progress" events: params.progress = "download" print(multipart:toString()); network.request( "http://merchants.duice.co/api/duices", "POST", uploadListener, params)
I’ve attached the two base64 encoded image too. To further confirm its a problem to do with the base64 length , Postmen in Chrome also returns error when sending the high res image. Any help would be greatly appreciated, Thanks!