post https://example.com/nfs/directory
Create a directory.
Create a public or private directory either in the application's root directory or in SAFE Drive.
Only authorised requests can invoke this API.
Request Header
Authorization: Bearer <TOKEN>
Content-Type: application/json
Request Payload
{
isPrivate: Boolean,
metadata: base64 String,
}
Field | Description |
---|---|
isPrivate | Boolean value to indicate the directory should be either private or public. |
metadata | The metadata to be associated with the directory. It should be encoded as a base64 string. This is an optional field. If not specified, it defaults to an empty string. |
Response
Ok
Unauthorized
Fields are missing
Examples
var request = require('request');
var endPoint = 'http://localhost:8100/nfs/directory/app/home/pics';
var payload = {
isPrivate: true,
metadata: new Buffer('sample metadata').toString('base64')
};
var onResponse = function(err, response, body) {
if (err) {
return console.error(err.message);
}
if (response.statusCode === 401) {
return console.error('Failed to authorise');
}
if (response.statusCode === 200) {
return console.log('Directory created');
}
console.error('Failed to create directory.', body);
};
request.post(endPoint, {
auth: {
bearer: constants.token // pass the auth token
},
json: true,
body: payload
}, onResponse);