Skip to content
Snippets Groups Projects
Commit b95fd7a3 authored by echicken's avatar echicken :chicken:
Browse files

Don't melt nobody's compooters mkay?

parent 03bb6dff
Branches
Tags
No related merge requests found
......@@ -3,6 +3,8 @@ load(settings.web_lib + 'auth.js');
load(settings.web_lib + 'files.js');
load('filebase.js');
var CHUNK_SIZE = 1024;
var reply = {};
if ((http_request.method === 'GET' || http_request.method === 'POST') &&
typeof http_request.query.call !== 'undefined' && user.number > 0
......@@ -34,9 +36,10 @@ if ((http_request.method === 'GET' || http_request.method === 'POST') &&
http_reply.header['Content-Length'] = file_size(file.path);
var f = new File(file.path);
f.open('rb');
for (var n = 0; n < file_size(file.path); n++) {
for (var n = 0; n < f.length; n += CHUNK_SIZE) {
var r = f.length - f.position;
write(f.read(r > 512 ? 512 : r));
write(f.read(r > CHUNK_SIZE ? CHUNK_SIZE : r));
yield(false);
}
f.close();
reply = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment