mirror of
https://github.com/leanote/desktop-app.git
synced 2026-01-14 07:04:21 +08:00
88
node_modules/api.js
generated
vendored
88
node_modules/api.js
generated
vendored
@@ -103,7 +103,7 @@ var Api = {
|
||||
// console.log('login ret');
|
||||
// console.log(ret);
|
||||
if(Common.isOk(ret)) {
|
||||
ret.Pwd = pwd;
|
||||
ret.Pwd = Common.md5(pwd, ret.UserId);
|
||||
ret['Host'] = Evt.leanoteUrl;
|
||||
User.setCurUser(ret);
|
||||
callback && callback(ret);
|
||||
@@ -113,45 +113,10 @@ var Api = {
|
||||
}
|
||||
});
|
||||
},
|
||||
post: function() {
|
||||
var me = this;
|
||||
var options = {
|
||||
headers: { 'X-Custom-Header': 'Bumbaway atuna' }
|
||||
}
|
||||
// you can pass params as a string or as an object.
|
||||
needle.post(me.getUrl('auth/login'), 'foo=bar', options, function(err, resp) {
|
||||
var ret = resp.body;
|
||||
log(ret);
|
||||
});
|
||||
},
|
||||
// get图片
|
||||
getImageTest: function(callback) {
|
||||
needle.get('http://localhost:9000/images/logo.png', function(err, resp) {
|
||||
// log(resp.body);
|
||||
/*
|
||||
{ 'accept-ranges': 'bytes',
|
||||
'content-disposition': 'inline; filename="logo.png"',
|
||||
'content-length': '8583',
|
||||
'content-type': 'image/png',
|
||||
date: 'Mon, 19 Jan 2015 15:01:47 GMT',
|
||||
*/
|
||||
// log(resp.headers);
|
||||
fs.writeFile('/Users/life/Desktop/aa.png', resp.body);
|
||||
});
|
||||
},
|
||||
// 测试
|
||||
uploadImage: function() {
|
||||
var data = {
|
||||
foo: 'bar',
|
||||
cc: [1,2,3,3],
|
||||
dd: {name: 'life', age: 18},
|
||||
image: { file: '/Users/life/Desktop/imageplus.png', content_type: 'image/png' }
|
||||
}
|
||||
needle.post('http://localhost/phpinfo.php', data, { multipart: true }, function(err, resp, body) {
|
||||
// needle will read the file and include it in the form-data as binary
|
||||
console.log(resp.body);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
getSyncNotebooks: function(afterUsn, maxEntry, callback) {
|
||||
var me = this;
|
||||
var url = this.getUrl('notebook/getSyncNotebooks', {afterUsn: afterUsn, maxEntry: maxEntry});
|
||||
@@ -749,10 +714,53 @@ var Api = {
|
||||
});
|
||||
},
|
||||
|
||||
//---------------
|
||||
// just for fun
|
||||
|
||||
test: function() {
|
||||
log("??");
|
||||
Note = require('note');
|
||||
log(Note);
|
||||
},
|
||||
|
||||
post: function() {
|
||||
var me = this;
|
||||
var options = {
|
||||
headers: { 'X-Custom-Header': 'Bumbaway atuna' }
|
||||
}
|
||||
// you can pass params as a string or as an object.
|
||||
needle.post(me.getUrl('auth/login'), 'foo=bar', options, function(err, resp) {
|
||||
var ret = resp.body;
|
||||
log(ret);
|
||||
});
|
||||
},
|
||||
// get图片
|
||||
getImageTest: function(callback) {
|
||||
needle.get('http://localhost:9000/images/logo.png', function(err, resp) {
|
||||
// log(resp.body);
|
||||
/*
|
||||
{ 'accept-ranges': 'bytes',
|
||||
'content-disposition': 'inline; filename="logo.png"',
|
||||
'content-length': '8583',
|
||||
'content-type': 'image/png',
|
||||
date: 'Mon, 19 Jan 2015 15:01:47 GMT',
|
||||
*/
|
||||
// log(resp.headers);
|
||||
fs.writeFile('/Users/life/Desktop/aa.png', resp.body);
|
||||
});
|
||||
},
|
||||
// 测试
|
||||
uploadImage: function() {
|
||||
var data = {
|
||||
foo: 'bar',
|
||||
cc: [1,2,3,3],
|
||||
dd: {name: 'life', age: 18},
|
||||
image: { file: '/Users/life/Desktop/imageplus.png', content_type: 'image/png' }
|
||||
}
|
||||
needle.post('http://localhost/phpinfo.php', data, { multipart: true }, function(err, resp, body) {
|
||||
// needle will read the file and include it in the form-data as binary
|
||||
console.log(resp.body);
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user