|
ticket id 000008 |
status open |
priority ??? |
assigned to NOBODY |
Reported by: Component: |
In some cases image storing leads to incomplete download. In my case the actual file size is 955 bytes, but downloaded data size is 954.
require("mime")
require("ltn12")
local base64_wrap = ltn12.filter.chain(mime.encode("base64"), mime.wrap("base64"))
local data = assert (io.open ("image.png")):read ("*a");
local encoded = base64_wrap (data);
local decoded = mime.unb64 (encoded);
print (#decode, "of", #data);
The output is 954 of 955
But if we use local encoded = mime.wrap("base64") (mime.b64 (data)) instead of local encoded = base64_wrap (data); we'll have 955 of 955
So here's the diff for 'sputnik/actions/binaryfile.lua': Tickets/000008/diff
Well, it seems to be, there's a cleaner way:
local b64filter = mime.encode("base64")
local encoded = b64filter (data)..b64filter ()