Error: Maximum size of base64 image encoded file in Multi-part form "POST" Upload

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!

Anyone can help with this? If the answer is no and theres nothing i can do about it is useful too. Uploading an image with params would be an essential part to the network component.

Hi, I am currently facing exact problem. Uploading image with params should be supported.

I tried to download the files to my Mac and run the built in base64 decoder.  Both files claimed to have invalid characters in their stream.

If the small one works but the large one does not perhaps the problem is on the hosting side.  Sometimes the upload script may have limits on how big the file can be.

Rob

What’s the http error code ? I would go with Rob, as it sounds more like a server config.

Most servers has a 2MB default set on it.

If you are on PHP, check it out your php.info and look for these items :

post\_max\_size upload\_max\_filesize

Anyone can help with this? If the answer is no and theres nothing i can do about it is useful too. Uploading an image with params would be an essential part to the network component.

Hi, I am currently facing exact problem. Uploading image with params should be supported.

I tried to download the files to my Mac and run the built in base64 decoder.  Both files claimed to have invalid characters in their stream.

If the small one works but the large one does not perhaps the problem is on the hosting side.  Sometimes the upload script may have limits on how big the file can be.

Rob

What’s the http error code ? I would go with Rob, as it sounds more like a server config.

Most servers has a 2MB default set on it.

If you are on PHP, check it out your php.info and look for these items :

post\_max\_size upload\_max\_filesize