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

16
LINES

< > BotCompany Repo | #1013807 // serveFileWithName

JavaX fragment (include)

1  
static NanoHTTPD.Response serveFileWithName(File file) {
2  
  ret serveFileWithName(file, file.getName());
3  
}
4  
5  
static NanoHTTPD.Response serveFileWithName(File file, S name) {
6  
  ret serveWithFileName_addName(serveFile(file), name);
7  
}
8  
9  
static NanoHTTPD.Response serveWithFileName_addName(NanoHTTPD.Response r, S name) {
10  
  r.addHeader("Content-Disposition", "inline; filename=\"" + name + "\""); // todo: encode special characters
11  
  ret r;
12  
}
13  
14  
static NanoHTTPD.Response serveFileWithName(File file, S name, S mimeType) {
15  
  ret serveWithFileName_addName(serveFile(file, mimeType), name);
16  
}

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: 369 / 402
Version history: 3 change(s)
Referenced in: [show references]