|
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | +<!DOCTYPE html> |
| 5 | + |
| 6 | +<html lang=en> |
| 7 | + |
| 8 | + <head> |
| 9 | + <meta charset=utf-8> |
| 10 | + |
| 11 | + <title> |
| 12 | + file-server.js |
| 13 | + </title> |
| 14 | + |
| 15 | + <meta name=description content=''> |
| 16 | + |
| 17 | + <base href='https://ext-code.com/libs/js/io/file-server/'> |
| 18 | + <link rel=canonical href='https://ext-code.com/libs/js/io/file-server/file-server.html'> |
| 19 | + |
| 20 | + <meta name=viewport content='width=device-width, initial-scale=1'> |
| 21 | + <link rel=icon href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAMAAAAM7l6QAAABAlBMVEVHcEzwShbtTxrzbhXyoSHyORLyTRPzXxTzZxXzqB/upCjyRRP0ixfpOB31qBnyTxTvOBTtMBX1nhjxLBH1phr0nhvwMBPtNxb0hhfubRzzeBbyaxjxbBr0jBr0hRnyQhP0jhfzlBzzrB70gxbxPRP0kxjypiD0rBz0mRnzox/uKhLzfhjzoR3xPRPzmRn0kxjvKhPwMhL1oxnwMxP1oxryWBXyeRnxXRfzfRbyfhryVxXycxfybRjwchrzbRXxeBnyaRjzchbyYxbzYhXxXxfzaBbtKxTuKhP0qx3zrB7xZhrxZhn1pRjxMBHzUhPyRRP0jhf0iBf0kxf1mRj0gxb0fRW9Ofp/AAAATHRSTlMAHxH+EP3g/f42CIF/CPZ/izb89ruLuyjgG/x/Ux8f3+AeWoDO3yB4ziV4eyuzs4JL6+vQ0HtYWOUk5dGMRfFnjOjR6GjxWlpLS0VFZBEF4QAAATVJREFUKM+tk9eygjAURaWJoFgREOy9997rrYD9/3/lwsCEBJ/ujDztlcXsk4TB43nHg3frH5wVuc96F0dtRIhpsYidjShEYCsONK0nYBZgQk/TBiKkwxQVFkEhLpoMDS5SLQ5u41pU0RmPZc5+dC/+cwZztPdVe2Gth1Ad0v+h5/oI1SN97ugjTU9QPaHpo32qX+VA7xOoTuzpg/Jjnm3r8/lOSfc3SJ6M5a0RlgRBrF/12lhemuUrZUcs3OULYqes7IvbyPIY1WNZ3gCYTZ8NVDee0xmAtPQooLrwkNIAUtI1gOrAFdbZi1tfsikAudKtg+rOrZQDQFbvbRa2bPteJR2MR6PxJmCyaTL0dm2oqn2+bEGZ76vqsAa3MXxQDTJ2NiLPoHshvyp5ezybr3yTb/m3/gB3/SLZj0tcfgAAAABJRU5ErkJggg=='> |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + <script src='https://libs.ext-code.com/js/dom/component/component.js'></script> |
| 26 | + <script src='https://libs.ext-code.com/js/dom/init-hdr/init-hdr.js'></script> |
| 27 | + |
| 28 | + <script> |
| 29 | + |
| 30 | + |
| 31 | + function start(){ |
| 32 | + debug('start'); |
| 33 | + initdom(); |
| 34 | + |
| 35 | + }//start |
| 36 | + |
| 37 | + |
| 38 | + </script> |
| 39 | + |
| 40 | + <style> |
| 41 | + |
| 42 | + html |
| 43 | + {font-family:arial} |
| 44 | + |
| 45 | + |
| 46 | + #hdr |
| 47 | + {display:flex;justify-content:space-between} |
| 48 | + #hdr>div:first-of-type |
| 49 | + {display:flex;gap:20px} |
| 50 | + |
| 51 | + code |
| 52 | + {display:block;white-space:pre;font-family:monospace;margin:20px;padding:20px;background:whitesmoke} |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + web-editor |
| 57 | + {display:block;height:200px;margin:20px;border:1px solid lightgray;padding:10px} |
| 58 | + |
| 59 | + |
| 60 | + input |
| 61 | + {font-size:16px;padding:5px 10px} |
| 62 | + input[type=button] |
| 63 | + {cursor:pointer} |
| 64 | + |
| 65 | + |
| 66 | + </style> |
| 67 | + |
| 68 | + </head> |
| 69 | + |
| 70 | + |
| 71 | + <body> |
| 72 | + |
| 73 | + |
| 74 | + <div id=hdr> |
| 75 | + |
| 76 | + <div> |
| 77 | + <a href='https://ext-code.com/'> |
| 78 | + home |
| 79 | + </a> |
| 80 | + |
| 81 | + <a href='../../../code.html'> |
| 82 | + libs |
| 83 | + </a> |
| 84 | + </div> |
| 85 | + |
| 86 | + <h1> |
| 87 | + libs/js/io/file-server/file-server.js |
| 88 | + </h1> |
| 89 | + |
| 90 | + <div> |
| 91 | + 19 Dec 2025 |
| 92 | + </div> |
| 93 | + |
| 94 | + </div hdr> |
| 95 | + |
| 96 | + |
| 97 | + <div> |
| 98 | + |
| 99 | + |
| 100 | + <p> |
| 101 | + This library interfaces the server to expose direct file system operations to the browser through a simple fetch‑based API. By sending requests such as |
| 102 | + </p> |
| 103 | + |
| 104 | + <div> |
| 105 | + <input value=download type=button> |
| 106 | + </div> |
| 107 | + |
| 108 | + <code> |
| 109 | + |
| 110 | + fetch('https://localhost:3000/a.txt',{headers:{mode:'load',auth:'my-auth'}}) |
| 111 | + |
| 112 | + </code> |
| 113 | + |
| 114 | + <p> |
| 115 | + the browser can interact with local files securely and consistently. |
| 116 | + </p> |
| 117 | + |
| 118 | + <p> |
| 119 | + Supported operations include: |
| 120 | + </p> |
| 121 | + |
| 122 | + <p> |
| 123 | + load → retrieve file contents |
| 124 | + </p> |
| 125 | + |
| 126 | + <p> |
| 127 | + save → write or overwrite file data |
| 128 | + </p> |
| 129 | + |
| 130 | + <p> |
| 131 | + file delete → remove a file |
| 132 | + </p> |
| 133 | + |
| 134 | + <p> |
| 135 | + dir read → list directory contents |
| 136 | + </p> |
| 137 | + |
| 138 | + <p> |
| 139 | + dir create → make a new directory |
| 140 | + </p> |
| 141 | + |
| 142 | + <p> |
| 143 | + dir delete → remove a directory |
| 144 | + </p> |
| 145 | + |
| 146 | + <p> |
| 147 | + Together, these commands provide a complete set of standard file I/O capabilities accessible from the browser. This member sits at the Code stage of the pipeline: more substantial than a library, since it defines a working server with a defined protocol, but not yet a full project. It serves as a foundation for building browser‑driven file management tools, developer utilities, or experimental web‑native applications. |
| 148 | + </p> |
| 149 | + |
| 150 | + </div> |
| 151 | + |
| 152 | + <web-editor component fullsize src='https://libs.ext-code.com/js/io/file-server/file-server.js'></web-editor> |
| 153 | + |
| 154 | + </body> |
| 155 | + |
| 156 | + <script> |
| 157 | + |
| 158 | + |
| 159 | + var jszip; |
| 160 | + |
| 161 | + |
| 162 | + var btn = {}; |
| 163 | + |
| 164 | + |
| 165 | + //: |
| 166 | + |
| 167 | + |
| 168 | + function initdom(){ |
| 169 | + |
| 170 | + $('[value=download]').onclick = btn.download; |
| 171 | + |
| 172 | + }//initdom |
| 173 | + |
| 174 | + |
| 175 | + //: |
| 176 | + |
| 177 | + |
| 178 | + btn.download = async function(){ |
| 179 | + |
| 180 | + |
| 181 | + var res = await fetch('https://raw.githubusercontent.com/javascript-2020/libs/main/io/file-server/file-server.js'); |
| 182 | + var blob = await res.blob(); |
| 183 | + |
| 184 | + var url = window.URL.createObjectURL(blob); |
| 185 | + var a = document.createElement('a'); |
| 186 | + a.download = 'file-server'; |
| 187 | + a.href = url; |
| 188 | + a.click(); |
| 189 | + |
| 190 | + }//download |
| 191 | + |
| 192 | + |
| 193 | + </script> |
| 194 | + |
| 195 | +</html> |
| 196 | + |
| 197 | + |
| 198 | + |
| 199 | + |
| 200 | + |
0 commit comments