Permalink
Browse files

added support for binary streams for attachments

  • Loading branch information...
Andris Reinman
Andris Reinman committed Feb 28, 2012
1 parent 06eb6cb commit 80bd5a37bd1c40228f51876fc53c390a30888870
View
@@ -262,10 +262,11 @@ Attahcment object consists of the following properties:
* **cid** - optional content id for using inline images in HTML message source
* **contents** - String or a Buffer contents for the attachment
* **filePath** - path to a file if you want to stream the file instead of including it (better for larger attachments)
+ * **streamSource** - Stream object for arbitrary binary streams if you want to stream the contents (needs to support *pause*/*resume*)
* **contentType** - optional content type for the attachment, if not set will be derived from the `fileName` property
-One of `contents` or `filePath` must be specified, if both are missing, the attachment
-will be discarded. Other fields are optional.
+One of `contents`, `filePath` or `streamSource` must be specified, if none is
+present, the attachment will be discarded. Other fields are optional.
Attachments can be added as many as you want.
@@ -284,6 +285,10 @@ Attachments can be added as many as you want.
fileName: "text3.txt",
filePath: "/path/to/file.txt" // stream this file
},
+ {
+ fileName: "text4.txt",
+ streamSource: fs.createReadStream("file.txt")
+ },
{
fileName: "text",
contents: "hello world!,
@@ -57,7 +57,7 @@ <h2 class="heading1">Classes</h2>
Documentation generator: <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.4.0<br />
Template: <a href="http://www.thebrightlines.com/2010/05/06/new-template-for-jsdoctoolkit-codeview/" target="_blank">Codeview</a> 1.2<br />
Generated on:
- <time datetime='2012-1-15' pubdate>2012-1-15 11:43</time>
+ <time datetime='2012-1-28' pubdate>2012-1-28 12:20</time>
</footer>
</div>
</div>
@@ -57,7 +57,7 @@ <h2 class="heading1">Classes</h2>
Documentation generator: <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.4.0<br />
Template: <a href="http://www.thebrightlines.com/2010/05/06/new-template-for-jsdoctoolkit-codeview/" target="_blank">Codeview</a> 1.2<br />
Generated on:
- <time datetime='2012-1-15' pubdate>2012-1-15 11:43</time>
+ <time datetime='2012-1-28' pubdate>2012-1-28 12:20</time>
</footer>
</div>
</div>
@@ -148,7 +148,7 @@
<span class='line'>141</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"\n-\u0001\u0001--\u0001\u0001--\u0001\u0001--\u0001\u0001-"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">spaces</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>143</span>
-<span class='line'>144</span> </span><span class="WHIT"> </span><span class="NAME">content</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">content.replace</span><span class="PUNC">(</span><span class="REGX">/&lt;/g</span><span class="PUNC">,</span><span class="STRN">"&lt;"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/>/g</span><span class="PUNC">,</span><span class="STRN">"&gt;"</span><span class="PUNC">)</span><span class="WHIT">
+<span class='line'>144</span> </span><span class="WHIT"> </span><span class="NAME">content</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">content.replace</span><span class="PUNC">(</span><span class="REGX">/&lt;/g</span><span class="PUNC">,</span><span class="STRN">"&lt;"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/>/g</span><span class="PUNC">,</span><span class="STRN">"&gt;"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span>
<span class='line'>146</span> </span><span class="WHIT"> </span><span class="COMM">// add prepending 4 spaces</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"\n-\u0001\u0001--\u0001\u0001--\u0001\u0001--\u0001\u0001-"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">content.trim</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"\n\n"</span><span class="PUNC">;</span><span class="WHIT">
Oops, something went wrong.

0 comments on commit 80bd5a3

Please sign in to comment.