<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[send静态文件模块 - Node.js参考——模具行业从业者必备知识手册]]></title><description><![CDATA[<p dir="auto">&lt;h2&gt;send&lt;/h2&gt;</p>
<p dir="auto">&lt;p&gt;[![NPM Version][npm-version-image&rsqb;&rsqb;[npm-url]&lt;/p&gt;<br />
&lt;p&gt;[![NPM Downloads][npm-downloads-image&rsqb;&rsqb;[npm-url]&lt;/p&gt;<br />
&lt;p&gt;[![Linux Build][github-actions-ci-image&rsqb;&rsqb;[github-actions-ci-url]&lt;/p&gt;<br />
&lt;p&gt;[![Windows Build][appveyor-image&rsqb;&rsqb;[appveyor-url]&lt;/p&gt;<br />
&lt;p&gt;[![Test Coverage][coveralls-image&rsqb;&rsqb;[coveralls-url]&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;Send is a library for streaming files from the file system as a http response&lt;/p&gt;<br />
&lt;p&gt;supporting partial responses (Ranges), conditional-GET negotiation (If-Match,&lt;/p&gt;<br />
&lt;p&gt;If-Unmodified-Since, If-None-Match, If-Modified-Since), high test coverage,&lt;/p&gt;<br />
&lt;p&gt;and granular events which may be leveraged to take appropriate actions in your&lt;/p&gt;<br />
&lt;p&gt;application or framework.&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;Looking to serve up entire folders mapped to URLs? Try &lt;a href="<a href="https://www.npmjs.org/package/serve-static" rel="nofollow ugc">https://www.npmjs.org/package/serve-static</a>"&gt;serve-static&lt;/a&gt;.&lt;/p&gt;</p>
<p dir="auto">&lt;h3&gt;Installation&lt;/h3&gt;</p>
<p dir="auto">&lt;p&gt;This is a &lt;a href="<a href="https://nodejs.org/en/" rel="nofollow ugc">https://nodejs.org/en/</a>"&gt;Node.js&lt;/a&gt; module available through the&lt;/p&gt;<br />
&lt;p&gt;&lt;a href="<a href="https://www.npmjs.com/" rel="nofollow ugc">https://www.npmjs.com/</a>"&gt;npm registry&lt;/a&gt;. Installation is done using the&lt;/p&gt;<br />
&lt;p&gt;&lt;a href="<a href="https://docs.npmjs.com/getting-started/installing-npm-packages-locally" rel="nofollow ugc">https://docs.npmjs.com/getting-started/installing-npm-packages-locally</a>"&gt;&lt;code&gt;npm install&lt;/code&gt; command&lt;/a&gt;:&lt;/p&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
$ npm install send<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;h3&gt;API&lt;/h3&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
var send = require('send')<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;h4&gt;send(req, path, [options])&lt;/h4&gt;</p>
<p dir="auto">&lt;p&gt;Create a new &lt;code&gt;SendStream&lt;/code&gt; for the given path to send to a &lt;code&gt;res&lt;/code&gt;. The &lt;code&gt;req&lt;/code&gt; is&lt;/p&gt;<br />
&lt;p&gt;the Node.js HTTP request and the &lt;code&gt;path&lt;/code&gt; is a urlencoded path to send (urlencoded,&lt;/p&gt;<br />
&lt;p&gt;not the actual file-system path).&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;#### Options&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;##### acceptRanges&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;Enable or disable accepting ranged requests, defaults to true.&lt;/p&gt;<br />
&lt;p&gt;Disabling this will not send &lt;code&gt;Accept-Ranges&lt;/code&gt; and ignore the contents&lt;/p&gt;<br />
&lt;p&gt;of the &lt;code&gt;Range&lt;/code&gt; request header.&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;##### cacheControl&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;Enable or disable setting &lt;code&gt;Cache-Control&lt;/code&gt; response header, defaults to&lt;/p&gt;<br />
&lt;p&gt;true. Disabling this will ignore the &lt;code&gt;immutable&lt;/code&gt; and &lt;code&gt;maxAge&lt;/code&gt; options.&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;##### dotfiles&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;Set how "dotfiles" are treated when encountered. A dotfile is a file&lt;/p&gt;<br />
&lt;p&gt;or directory that begins with a dot ("."). Note this check is done on&lt;/p&gt;<br />
&lt;p&gt;the path itself without checking if the path actually exists on the&lt;/p&gt;<br />
&lt;p&gt;disk. If &lt;code&gt;root&lt;/code&gt; is specified, only the dotfiles above the root are&lt;/p&gt;<br />
&lt;p&gt;checked (i.e. the root itself can be within a dotfile when when set&lt;/p&gt;<br />
&lt;p&gt;to "deny").&lt;/p&gt;</p>
<p dir="auto">&lt;ul&gt;<br />
&lt;li&gt;&lt;code&gt;'allow'&lt;/code&gt; No special treatment for dotfiles.&lt;/li&gt;<br />
&lt;li&gt;&lt;code&gt;'deny'&lt;/code&gt; Send a 403 for any request for a dotfile.&lt;/li&gt;<br />
&lt;li&gt;&lt;code&gt;'ignore'&lt;/code&gt; Pretend like the dotfile does not exist and 404.&lt;/li&gt;<br />
&lt;/ul&gt;</p>
<p dir="auto">&lt;p&gt;The default value is <em>similar</em> to &lt;code&gt;'ignore'&lt;/code&gt;, with the exception that&lt;/p&gt;<br />
&lt;p&gt;this default will not ignore the files within a directory that begins&lt;/p&gt;<br />
&lt;p&gt;with a dot, for backward-compatibility.&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;##### end&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;Byte offset at which the stream ends, defaults to the length of the file&lt;/p&gt;<br />
&lt;p&gt;minus 1. The end is inclusive in the stream, meaning &lt;code&gt;end: 3&lt;/code&gt; will include&lt;/p&gt;<br />
&lt;p&gt;the 4th byte in the stream.&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;##### etag&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;Enable or disable etag generation, defaults to true.&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;##### extensions&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;If a given file doesn't exist, try appending one of the given extensions,&lt;/p&gt;<br />
&lt;p&gt;in the given order. By default, this is disabled (set to &lt;code&gt;false&lt;/code&gt;). An&lt;/p&gt;<br />
&lt;p&gt;example value that will serve extension-less HTML files: &lt;code&gt;['html', 'htm']&lt;/code&gt;.&lt;/p&gt;<br />
&lt;p&gt;This is skipped if the requested file already has an extension.&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;##### immutable&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;Enable or disable the &lt;code&gt;immutable&lt;/code&gt; directive in the &lt;code&gt;Cache-Control&lt;/code&gt; response&lt;/p&gt;<br />
&lt;p&gt;header, defaults to &lt;code&gt;false&lt;/code&gt;. If set to &lt;code&gt;true&lt;/code&gt;, the &lt;code&gt;maxAge&lt;/code&gt; option should&lt;/p&gt;<br />
&lt;p&gt;also be specified to enable caching. The &lt;code&gt;immutable&lt;/code&gt; directive will prevent&lt;/p&gt;<br />
&lt;p&gt;supported clients from making conditional requests during the life of the&lt;/p&gt;<br />
&lt;p&gt;&lt;code&gt;maxAge&lt;/code&gt; option to check if the file has changed.&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;##### index&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;By default send supports "index.html" files, to disable this&lt;/p&gt;<br />
&lt;p&gt;set &lt;code&gt;false&lt;/code&gt; or to supply a new index pass a string or an array&lt;/p&gt;<br />
&lt;p&gt;in preferred order.&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;##### lastModified&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;Enable or disable `Last-Modif&lt;/p&gt;</p>
<p dir="auto">&lt;hr&gt;<br />
&lt;p&gt;踩过坑的来评论区说说。&lt;/p&gt;</p>
]]></description><link>https://forum.mj7.cn/topic/7265/send静态文件模块-node-js参考-模具行业从业者必备知识手册</link><generator>RSS for Node</generator><lastBuildDate>Fri, 02 Oct 2026 07:36:10 GMT</lastBuildDate><atom:link href="https://forum.mj7.cn/topic/7265.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 19 Apr 2026 22:32:33 GMT</pubDate><ttl>60</ttl></channel></rss>