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

19
LINES

< > BotCompany Repo | #1003197 // serveFile - serve a file within serveHttp

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5158L/36K).

1  
ifdef NoNanoHTTPD
2  
static virtual NanoHTTPD.Response serveFile(File file) {
3  
  ret subBot_serveFile(file);
4  
}
5  
6  
static virtual NanoHTTPD.Response serveFile(File file, S mimeType) {
7  
  ret subBot_serveFile(file, mimeType);
8  
}
9  
endifdef
10  
11  
ifndef NoNanoHTTPD
12  
static NanoHTTPD.Response serveFile(File file) {
13  
  ret serveFile(file, "application/octet-stream");
14  
}
15  
16  
static NanoHTTPD.Response serveFile(File file, S mimeType) ctex {
17  
  ret NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Status.OK, mimeType, newFileInputStream(file), file.length());
18  
}
19  
endifndef

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: #1003197
Snippet name: serveFile - serve a file within serveHttp
Eternal ID of this version: #1003197/8
Text MD5: f82ffd8a9f222cc9a8e5a827c748a2fc
Transpilation MD5: eb6dcecb0385a8fdf43db7eef77187e6
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-11 16:45:18
Source code size: 558 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 771 / 769
Version history: 7 change(s)
Referenced in: [show references]