ymyang / fdfs Goto Github PK
View Code? Open in Web Editor NEWFastDFS nodejs client
FastDFS nodejs client
fdfs.upload('e:/shou.jpg').then(function(fileId) {
// fileId 为 group + '/' + filename
console.log(fileId);
}).catch(function(err) {
console.error(err);
); //cache function error, no }
要用阿里云SLB对tracker做负载均衡和健康检查,但tracker allow_hosts不支持阿里云SLB健康检查地址网段 100.64.0.0/10
参考: 7. HTTP监听向后端ECS实例执行健康检查的IP地址是什么?
配置:
allow_hosts=10.2.14.0/23
allow_hosts=100.64.0.0/10
[2019-05-22 21:52:25] ERROR - file: shared_func.c, line: 1620, ip address: 100.64.0.0/10, invalid network bits: 10, it should >= 16 and < 32
[2019-05-22 21:52:25] CRIT - exit abnormally!
当我在调用upload append模式时首次添加数据后再调研append追加
反回的storage与首次上传的文件storage不是同一个,导致出现错误
如下
receive server packet headerBuffer: {"type":"Buffer","data":[0,0,0,0,0,0,0,0,100,2]}
{ Error: receive packet errno is: 2
at _parseHeader (server\node_modules\fdfs\lib\protocol.js:334:19)
at Socket.listener (node_modules\fdfs\lib\protocol.js:183:34)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:551:20) errno: 2, code: 2 }
就目前观察是由于storage在每次追加时返回的不是源storage导致的,帮忙看看是不是?谢谢
招高级node.js,base上海。
fdfs can set store_path_index to save
环境
node v6.10.2
os: ubuntu 16
出错代码
let config= {
fdfs: {
upload: {
host: 'xxx',
port: 'xxx'
},
download: {
host: 'xxx'
},
size: 1024000
}
};
let getFdfs = (fdfs)=> {
return new FdfsClient({
// tracker servers
trackers: [
{
// host: process.env.FDFS_UPLOAD,
host: fdfs.upload.host,
port: fdfs.upload.port
}
],
// 默认超时时间10s
timeout: 1000000,
// 默认后缀
// 当获取不到文件后缀时使用
defaultExt: 'png',
// charset默认utf8
charset: 'utf8'
});
};
//busboy.......
busboy.on('file', function (fieldname, file, filename, encoding, mimetype) {
let fdfs = getFdfs(config.fdfs);
console.log('hei.......................................how are you')
fdfs.upload(file, {size: config.fdfs.size}).then(function(fileId) {
console.log('how ok ...........................')
console.log(fileId);
})
})
[输出]
一直卡在 start upload file to storage server 这一个步不动了
hei.......................................how are you
connect to tracker server [192.168.0.40:22122]
tracker server [192.168.0.40:22122] is connected
get a upload storage server from tracker server: [192.168.0.40:22122]
send header to tracker server [192.168.0.40:22122]
receive server packet header: {"status":0,"bodyLength":40}
get store storage server info: {"group":"group1","host":"192.168.0.41","port":23000,"storePathIndex":0,"timeout":10000,"charset":"utf8"}
connect to storage server [192.168.0.41:23000].
storage server [192.168.0.41:23000] is connected
start upload file to storage server [192.168.0.41:23000]
我就按照你的README一字不差写的,报错:
ReferenceError: FdfsClient is not defined
at Object. (E:\程序设计\nodejs\test_upload\test_upload.js:3:16)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
没有发现可以支持从文件的上传方法。有STORAGE_PROTO_CMD_UPLOAD_SLAVE_FILE
这个命令声明却没有对应的方法?或者有没有相应的思路?
receive command: 32 is not equal to the expected command: 100
是客户端问题还是fastdfs部署的tracker或store server的问题
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.