w-dwdata-ftp
Version:
A downloader for ftp data.
1,439 lines (467 loc) • 26.6 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>Global - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#WDwdataFtp">WDwdataFtp</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">Global</h1>
<section>
<header>
<h2>
</h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="WDwdataFtp"><span class="type-signature type-signature-async">(async) </span>WDwdataFtp<span class="signature">(st, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Object}</span></h4>
<dl class="details">
<dt class="tag-description">Description:</dt>
<dd class="tag-description"><ul class="dummy"><li><p>基於檔案之下載FTP數據與任務建構器</p>
<p>執行階段最新hash數據放置於fdDwAttime,前次hash數據會於結束前自動備份至fdDwCurrent</p>
<p>執行階段最新數據放置於fdDwStorageTemp,前次數據放置於fdDwStorage,於結束前會將fdDwStorage清空,將fdDwStorageTemp複製至fdDwStorage</p></li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="WDwdataFtp.mjs.html">WDwdataFtp.mjs</a>, <a href="WDwdataFtp.mjs.html#line149">line 149</a>
</li></ul></dd>
</dl>
<h5 class="h5-examples">Example</h5>
<pre class="prettyprint"><code>import w from 'wsemi'
import WDwdataFtp from './src/WDwdataFtp.mjs'
let st = {
'hostname': '{hostname}',
'port': 21,
'username': '{username}',
'password': '{password}',
'fdIni': './'
}
// console.log('st', st)
//fdTagRemove
let fdTagRemove = `./_tagRemove`
w.fsCleanFolder(fdTagRemove)
//fdDwStorageTemp
let fdDwStorageTemp = `./_dwStorageTemp`
w.fsCleanFolder(fdDwStorageTemp)
//fdDwStorage
let fdDwStorage = `./_dwStorage`
w.fsCleanFolder(fdDwStorage)
//fdDwAttime
let fdDwAttime = `./_dwAttime`
w.fsCleanFolder(fdDwAttime)
//fdDwCurrent
let fdDwCurrent = `./_dwCurrent`
w.fsCleanFolder(fdDwCurrent)
//fdResult
let fdResult = `./_result`
w.fsCleanFolder(fdResult)
//fdTaskCpActualSrc
let fdTaskCpActualSrc = `./_taskCpActualSrc`
w.fsCleanFolder(fdTaskCpActualSrc)
//fdTaskCpSrc
let fdTaskCpSrc = `./_taskCpSrc`
w.fsCleanFolder(fdTaskCpSrc)
let opt = {
useExpandOnOldFiles: false, //true, false
fdTagRemove,
fdDwStorageTemp,
fdDwStorage,
fdDwAttime,
fdDwCurrent,
fdResult,
fdTaskCpActualSrc,
fdTaskCpSrc,
// fdLog,
// funDownload,
// funGetCurrent,
// funRemove,
// funAdd,
// funModify,
}
let ev = await WDwdataFtp(st, opt)
.catch((err) => {
console.log(err)
})
ev.on('change', (msg) => {
delete msg.type
console.log('change', msg)
})
// change { event: 'start', msg: 'running...' }
// change { event: 'proc-callfun-afterStart', msg: 'start...' }
// change { event: 'proc-callfun-afterStart', msg: 'done' }
// change { event: 'proc-callfun-download', msg: 'start...' }
// change { event: 'proc-callfun-download', num: 2, msg: 'done' }
// change { event: 'proc-callfun-getCurrent', msg: 'start...' }
// change { event: 'proc-callfun-getCurrent', num: 0, msg: 'done' }
// change { event: 'proc-compare', msg: 'start...' }
// change { event: 'proc-compare', numRemove: 0, numAdd: 2, numModify: 0, numSame: 0, msg: 'done' }
// change { event: 'proc-add-callfun-add', id: 'test1.txt', msg: 'start...' }
// change { event: 'proc-add-callfun-add', id: 'test1.txt', msg: 'done' }
// change { event: 'proc-add-callfun-add', id: 'test2.txt', msg: 'start...' }
// change { event: 'proc-add-callfun-add', id: 'test2.txt', msg: 'done' }
// ...</code></pre>
<h5 class="h5-parameters">Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>st</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>輸入設定FTP連線資訊物件</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>transportation</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>'FTP'</code>
</td>
<td class="description last"><p>輸入傳輸協定字串,可選'FTP'、'SFTP',預設'FTP'</p></td>
</tr>
<tr>
<td class="name"><code>hostname</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>''</code>
</td>
<td class="description last"><p>輸入hostname字串,預設''</p></td>
</tr>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">Integer</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>21|22</code>
</td>
<td class="description last"><p>輸入port正整數,當transportation='FTP'預設21,當transportation='SFTP'預設22</p></td>
</tr>
<tr>
<td class="name"><code>username</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>''</code>
</td>
<td class="description last"><p>輸入帳號字串,預設''</p></td>
</tr>
<tr>
<td class="name"><code>password</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>''</code>
</td>
<td class="description last"><p>輸入密碼字串,預設''</p></td>
</tr>
<tr>
<td class="name"><code>fdIni</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>'./'</code>
</td>
<td class="description last"><p>輸入同步資料夾字串,預設'./'</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>opt</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>{}</code>
</td>
<td class="description last"><p>輸入設定物件,預設{}</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>useExpandOnOldFiles</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>false</code>
</td>
<td class="description last"><p>輸入來源檔案是否僅為增量檔案布林值,預設false</p></td>
</tr>
<tr>
<td class="name"><code>useSimulateFiles</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>false</code>
</td>
<td class="description last"><p>輸入是否使用模擬取得FTP數據布林值,預設false</p></td>
</tr>
<tr>
<td class="name"><code>fdTagRemove</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>'./_tagRemove'</code>
</td>
<td class="description last"><p>輸入暫存標記為刪除數據資料夾字串,預設'./_tagRemove'</p></td>
</tr>
<tr>
<td class="name"><code>fdDwStorageTemp</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>'./_dwStorageTemp'</code>
</td>
<td class="description last"><p>輸入最新下載檔案存放資料夾字串,預設'./_dwStorageTemp'</p></td>
</tr>
<tr>
<td class="name"><code>fdDwStorage</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>'./_dwStorage'</code>
</td>
<td class="description last"><p>輸入合併儲存檔案資料夾字串,預設'./_dwStorage'</p></td>
</tr>
<tr>
<td class="name"><code>fdDwAttime</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>'./_dwAttime'</code>
</td>
<td class="description last"><p>輸入當前下載供比對hash用之數據資料夾字串,預設'./_dwAttime'</p></td>
</tr>
<tr>
<td class="name"><code>fdDwCurrent</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>'./_dwCurrent'</code>
</td>
<td class="description last"><p>輸入已下載供比對hash用之數據資料夾字串,預設'./_dwCurrent'</p></td>
</tr>
<tr>
<td class="name"><code>fdResult</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>`./_result`</code>
</td>
<td class="description last"><p>輸入已下載數據所連動生成數據資料夾字串,預設<code>./_result</code></p></td>
</tr>
<tr>
<td class="name"><code>fdTaskCpActualSrc</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>'./_taskCpActualSrc'</code>
</td>
<td class="description last"><p>輸入任務狀態之來源端完整資料夾字串,預設'./_taskCpActualSrc'</p></td>
</tr>
<tr>
<td class="name"><code>fdTaskCpSrc</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>'./_taskCpSrc'</code>
</td>
<td class="description last"><p>輸入任務狀態之來源端資料夾字串,預設'./_taskCpSrc'</p></td>
</tr>
<tr>
<td class="name"><code>fdLog</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>'./_logs'</code>
</td>
<td class="description last"><p>輸入儲存log資料夾字串,預設'./_logs'</p></td>
</tr>
<tr>
<td class="name"><code>funDownload</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>null</code>
</td>
<td class="description last"><p>輸入取得最新下載檔案hash之函數,回傳資料陣列,預設null</p></td>
</tr>
<tr>
<td class="name"><code>funGetCurrent</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>null</code>
</td>
<td class="description last"><p>輸入取得已下載檔案hash之函數,回傳資料陣列,預設null</p></td>
</tr>
<tr>
<td class="name"><code>funAdd</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>null</code>
</td>
<td class="description last"><p>輸入當有新資料時,需要連動處理之函數,預設null</p></td>
</tr>
<tr>
<td class="name"><code>funModify</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>null</code>
</td>
<td class="description last"><p>輸入當有資料需更新時,需要連動處理之函數,預設null</p></td>
</tr>
<tr>
<td class="name"><code>funRemove</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>null</code>
</td>
<td class="description last"><p>輸入當有資料需刪除時,需要連動處理之函數,預設null</p></td>
</tr>
<tr>
<td class="name"><code>funAfterStart</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>null</code>
</td>
<td class="description last"><p>輸入偵測程序剛開始啟動時,需要處理之函數,預設null</p></td>
</tr>
<tr>
<td class="name"><code>funBeforeEnd</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>null</code>
</td>
<td class="description last"><p>輸入偵測程序要結束前,需要處理之函數,預設null</p></td>
</tr>
<tr>
<td class="name"><code>timeToleranceRemove</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>0</code>
</td>
<td class="description last"><p>輸入刪除任務之防抖時長,單位ms,預設0,代表不使用</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<h5 class="h5-returns">Returns:</h5>
<div class="param-desc">
<p>回傳事件物件,可呼叫函數on監聽change事件</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.4</a> on Tue Sep 23 2025 22:03:35 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
</body>
</html>