]>
git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/blob - src/actions.js
33e47aa66f04f169cbec8135638b2529bff90d7a
7 var superagent
= require('superagent'),
8 path
= require('path');
10 var server
= 'http://localhost:3000/api/files/';
12 function put(filePath
) {
13 var relativeFilePath
= path
.resolve(filePath
).slice(process
.cwd().length
+ 1);
14 superagent
.put(server
+ relativeFilePath
).attach('file', filePath
).end(function (error
, result
) {
15 if (error
) return console
.log('Failed', result
? result
.body : error
);
16 console
.log('Success', result
.body
);
20 function get(filePath
) {
21 var relativeFilePath
= path
.resolve(filePath
).slice(process
.cwd().length
+ 1);
22 superagent
.get(server
+ relativeFilePath
).end(function (error
, result
) {
23 if (error
) return console
.log('Failed', result
? result
.body : error
);
24 console
.log('Success', result
.body
);
28 function del(filePath
) {
29 var relativeFilePath
= path
.resolve(filePath
).slice(process
.cwd().length
+ 1);
30 superagent
.del(server
+ relativeFilePath
).end(function (error
, result
) {
31 if (error
) return console
.log('Failed', result
? result
.body : error
);
32 console
.log('Success', result
.body
);