Node文件上传
How it works
Dotload reads files from local hard disk, post the formdata built by rfc rules to the remote server. Data will be parsed and saved to the disk as files. All you need is a config.js
Simple Form Type
#First boundary
--<boundary><crlf>
# Field1
Content-Disposition:form-data; name="<fieldname1>"<crlf><crlf>
<value1><crlf>
--<boundary><crlf>
# Field2
Content-Disposition:form-data; name="<fieldname2>"<crlf><crlf>
<value2><crlf>
--<boundary><crlf>
# File1
Content-Disposition:form-data; name="<fieldname3>" filename="<filename1>"<crlf>
Content-Type: <mimetype><crlf><crlf> #optional
<binary file data><crlf>
--<boundary><crlf>
# File2
Content-Disposition:form-data; name="<fieldname4>" filename="<filename2>"<crlf>
Content-Type: <mimetype><crlf><crlf> #optional
<binary file data><crlf>
# Last boundary
--<boundary>--<crlf>
Usage
edit config.js first
module.exports = {
hostname: 'localhost', //host ip
port: 9000, // port
method: 'POST',
path: '/upload',
to: '/Users/xiaowen/work/dotload/test/target/'
}Server
- install npm i -S dotload
- vim server.js
const createServer = require('../lib/receiver')
const config = require('./config')
createServer(config)- start server
pm2 start server.js --name receiverServerClient
- install npm i -S dotload
- vim upload.js
const upload = require('../lib/upload')
const config = require('./config')
const uploadPath='test/source/'
upload(config,uploadPath)- test
node test/upload.jsTODO
- remove the dependency of formidable ,parse the data using node
- callback 2 promise

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
