We use the mime module mainly to decode and encode base 64 strings. Is there any reason why it’s not included on the HTML5 builds?
The mime.* library is part of LuaSockets. This adds nearly 3 megabytes to the size of the HTML5 project. So few Corona apps use the socket library and doing so to get to mime.* is adding a lot of overhead to your project.
Base64 encoding and decoding is a pretty simple process that can be done with various Lua string recipes. Until we add socket.* back as a plugin, you are best to google around to find some simple base64 encoding routines. There should be some already in Lua you could easily repurpose.
Rob
Hi,
Here is the b64 module from Coronium Core that might be helpful.
local mod = {} mod.b64\_enc = function(data) -- character table string local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' return ((data:gsub('.', function(x) local r,b='',x:byte() for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)\>0 and '1' or '0') end return r; end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x) if (#x \< 6) then return '' end local c=0 for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end return b:sub(c+1,c+1) end)..({ '', '==', '=' })[#data%3+1]) end mod.b64\_dec = function(data) -- character table string local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' data = string.gsub(data, '[^'..b..'=]', '') return (data:gsub('.', function(x) if (x == '=') then return '' end local r,f='',(b:find(x)-1) for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)\>0 and '1' or '0') end return r; end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x) if (#x ~= 8) then return '' end local c=0 for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end return string.char(c) end)) end return mod
-dev
Hi,
Here is a Corona HTML5 plugin as well https://github.com/develephant/corona-html5-base64-plugin
-dev
Thanks!
Your plugin “websockets” use “mime” in html5 too
And not working in html5
Hi,
The Websockets plugin is an implementation for Corona device builds. It also uses open-ssl which is not supported by HTML5 builds. Not all Marketplace plugins are able to run in HTML5 builds as noted in the compatibility section.
On that note, I have been meaning to build a JS plugin for Websockets that can be used in HTML5 builds. But those are not supported in the Marketplace at this time. I’ll probably release that next week sometime for no cost. You can then check the “platform” and use the proper plugin as needed.
-dev
The mime.* library is part of LuaSockets. This adds nearly 3 megabytes to the size of the HTML5 project. So few Corona apps use the socket library and doing so to get to mime.* is adding a lot of overhead to your project.
Base64 encoding and decoding is a pretty simple process that can be done with various Lua string recipes. Until we add socket.* back as a plugin, you are best to google around to find some simple base64 encoding routines. There should be some already in Lua you could easily repurpose.
Rob
Hi,
Here is the b64 module from Coronium Core that might be helpful.
local mod = {} mod.b64\_enc = function(data) -- character table string local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' return ((data:gsub('.', function(x) local r,b='',x:byte() for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)\>0 and '1' or '0') end return r; end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x) if (#x \< 6) then return '' end local c=0 for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end return b:sub(c+1,c+1) end)..({ '', '==', '=' })[#data%3+1]) end mod.b64\_dec = function(data) -- character table string local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' data = string.gsub(data, '[^'..b..'=]', '') return (data:gsub('.', function(x) if (x == '=') then return '' end local r,f='',(b:find(x)-1) for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)\>0 and '1' or '0') end return r; end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x) if (#x ~= 8) then return '' end local c=0 for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end return string.char(c) end)) end return mod
-dev
Hi,
Here is a Corona HTML5 plugin as well https://github.com/develephant/corona-html5-base64-plugin
-dev
Thanks!
Your plugin “websockets” use “mime” in html5 too
And not working in html5
Hi,
The Websockets plugin is an implementation for Corona device builds. It also uses open-ssl which is not supported by HTML5 builds. Not all Marketplace plugins are able to run in HTML5 builds as noted in the compatibility section.
On that note, I have been meaning to build a JS plugin for Websockets that can be used in HTML5 builds. But those are not supported in the Marketplace at this time. I’ll probably release that next week sometime for no cost. You can then check the “platform” and use the proper plugin as needed.
-dev