Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

16
LINES

< > BotCompany Repo | #1013807 // serveFileWithName

JavaX fragment (include)

static NanoHTTPD.Response serveFileWithName(File file) {
  ret serveFileWithName(file, file.getName());
}

static NanoHTTPD.Response serveFileWithName(File file, S name) {
  ret serveWithFileName_addName(serveFile(file), name);
}

static NanoHTTPD.Response serveWithFileName_addName(NanoHTTPD.Response r, S name) {
  r.addHeader("Content-Disposition", "inline; filename=\"" + name + "\""); // todo: encode special characters
  ret r;
}

static NanoHTTPD.Response serveFileWithName(File file, S name, S mimeType) {
  ret serveWithFileName_addName(serveFile(file, mimeType), name);
}

Author comment

Began life as a copy of #1003197

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1013807
Snippet name: serveFileWithName
Eternal ID of this version: #1013807/4
Text MD5: 1ba2511ddecfa30b88840a1677f73dae
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-04 17:24:51
Source code size: 596 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 366 / 398
Version history: 3 change(s)
Referenced in: [show references]