experiental ?mode=thumb to append to jpg files

This commit is contained in:
Massimo Melina 2020-08-01 20:46:46 +02:00
parent db2ad83c77
commit 21349e5c04

View File

@ -5339,6 +5339,29 @@ var
runEventScript('login') runEventScript('login')
end; //urlAuth end; //urlAuth
function thumb():Boolean;
var
b: rawbytestring;
s, e: integer;
begin
if mode <> 'thumb' then
exit(FALSE);
result:=TRUE;
b:=loadFile(f.resource, 0, 96*KILO);
s:= pos(rawbytestring(#$FF#$D8#$FF), b, 2);
if s > 0 then
e:=pos(rawbytestring(#$FF#$D9), b, s);
if (s=0) or (e=0) then
begin
data.conn.reply.mode:=HRM_NOT_FOUND;
exit;
end;
conn.reply.contentType:='image/jpeg';
conn.reply.mode:=HRM_REPLY;
conn.reply.bodyMode:=RBM_STRING;
conn.reply.body:=Copy(b, s, e-s+2);
end;
var var
b: boolean; b: boolean;
s: string; s: string;
@ -5698,6 +5721,9 @@ var
if notModified(conn, f) then // calling notModified before limitsExceededOnDownload makes possible for [download] to manipualate headers set here if notModified(conn, f) then // calling notModified before limitsExceededOnDownload makes possible for [download] to manipualate headers set here
exit; exit;
if thumb() then
Exit;
data.countAsDownload:=f.shouldCountAsDownload(); data.countAsDownload:=f.shouldCountAsDownload();
if data.countAsDownload and limitsExceededOnDownload() then if data.countAsDownload and limitsExceededOnDownload() then
exit; exit;