{"metadata":{"image":[],"title":"","description":""},"api":{"url":"/nfs/directory","auth":"required","examples":{"codes":[]},"method":"post","params":[{"name":"rootPath","type":"string","default":"","desc":"Accepted value - `app` or `drive`","required":true,"in":"path","ref":"","_id":"57a0b14cf8f3b620004a6435"},{"name":"directoryPath","type":"string","default":"","desc":"Full path of the directory","required":true,"in":"path","ref":"","_id":"57a0b14cf8f3b620004a6434"}],"results":{"codes":[{"code":"","status":401,"language":"text"}]},"settings":""},"next":{"description":"","pages":[]},"title":"/nfs/directory/:rootPath/:directoryPath","type":"endpoint","slug":"nfs-create-directory","excerpt":"Create a directory. \nCreate a public or private directory either in the application's root directory or in SAFE Drive.\nOnly authorised requests can invoke this API.","body":"### Request Header\n```\nAuthorization: Bearer <TOKEN>\nContent-Type: application/json\n```\n\n### Request Payload\n\n```\n{\n    isPrivate: Boolean,\n    metadata: base64 String,\n}\n```\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Field\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"isPrivate\",\n    \"0-1\": \"Boolean value to indicate the directory should be either private or public.\",\n    \"2-0\": \"nonce\",\n    \"2-1\": \"Nonce used for the ECDH-Key-Exchange with the SAFE Launcher. The nonce should be converted to a base64 string\",\n    \"3-0\": \"permissions\",\n    \"3-1\": \"List of permissions requested by the applications. Empty array to be passed if no permissions are needed. Else pass the list of permissions as String.\\n\\nPermitted permission keys:\\nSAFE_DRIVE_ACCESS\",\n    \"h-2\": \"\",\n    \"1-0\": \"metadata\",\n    \"1-1\": \"The metadata to be associated with the directory. It should be encoded as a base64 string.\\n\\nThis is an optional field. If not specified, it defaults to an empty string.\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]\n### Response\n[block:code]\n{\n  \"codes\": [\n    {\n      \"name\": 200,\n      \"code\": \"Ok\",\n      \"language\": \"json\",\n      \"status\": 200\n    },\n    {\n      \"code\": \"Unauthorized\",\n      \"language\": \"http\",\n      \"name\": \"401\"\n    },\n    {\n      \"code\": \"Fields are missing\",\n      \"language\": \"http\",\n      \"name\": \"400\"\n    }\n  ],\n  \"sidebar\": true\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\"\n}\n[/block]\n## Examples\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var request = require('request');\\n\\nvar endPoint = 'http://localhost:8100/nfs/directory/app/home/pics';\\nvar payload = {\\n  isPrivate: true,\\n  metadata: new Buffer('sample metadata').toString('base64')\\n};\\n\\nvar onResponse = function(err, response, body) {\\n  if (err) {\\n    return console.error(err.message);\\n  }\\n  if (response.statusCode === 401) {\\n    return console.error('Failed to authorise');\\n  }\\n  if (response.statusCode === 200) {\\n    return console.log('Directory created');\\n  }\\n  console.error('Failed to create directory.', body);\\n};\\n\\nrequest.post(endPoint, {\\n  auth: {\\n    bearer: constants.token // pass the auth token\\n  },\\n  json: true,\\n  body: payload\\n}, onResponse);\\n\",\n      \"language\": \"javascript\",\n      \"name\": \"Nodejs\"\n    }\n  ],\n  \"sidebar\": true\n}\n[/block]","updates":["56e8036c818c622000c8875e"],"order":5,"isReference":false,"hidden":true,"sync_unique":"","link_url":"","link_external":false,"_id":"5721e9c849df4f0e00528345","parentDoc":null,"createdAt":"2016-03-11T04:31:48.612Z","user":"564d9fcd1936752300aa6439","version":{"version":"0.5","version_clean":"0.5.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["5721e9c849df4f0e00528320","5721e9c849df4f0e00528321","5721e9c849df4f0e00528322","5721e9c849df4f0e00528323","5721e9c849df4f0e00528324","5721e9c849df4f0e00528325","5721e9c849df4f0e00528326","5721e9c849df4f0e00528327","5721e9c849df4f0e00528328","5721e9c849df4f0e00528329","5a6f6fc5043d990023daeb09"],"_id":"5721e9c849df4f0e0052831f","releaseDate":"2016-04-28T10:45:28.369Z","hasReference":true,"project":"5656d449a795770d00a2aec1","createdAt":"2016-04-28T10:45:28.369Z","hasDoc":true,"__v":2},"__v":2,"category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"SAFE Launcher API","slug":"safe-launcher-api-1","order":3,"from_sync":false,"reference":false,"_id":"5721e9c849df4f0e00528328","project":"5656d449a795770d00a2aec1","createdAt":"2016-03-07T18:25:17.849Z","__v":0,"version":"5721e9c849df4f0e0052831f"},"githubsync":"","project":"5656d449a795770d00a2aec1"}

post/nfs/directory/:rootPath/:directoryPath

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.

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Path Params

rootPath:
required
string
Accepted value - `app` or `drive`
directoryPath:
required
string
Full path of the directory

Documentation

### Request Header ``` Authorization: Bearer <TOKEN> Content-Type: application/json ``` ### Request Payload ``` { isPrivate: Boolean, metadata: base64 String, } ``` [block:parameters] { "data": { "h-0": "Field", "h-1": "Description", "0-0": "isPrivate", "0-1": "Boolean value to indicate the directory should be either private or public.", "2-0": "nonce", "2-1": "Nonce used for the ECDH-Key-Exchange with the SAFE Launcher. The nonce should be converted to a base64 string", "3-0": "permissions", "3-1": "List of permissions requested by the applications. Empty array to be passed if no permissions are needed. Else pass the list of permissions as String.\n\nPermitted permission keys:\nSAFE_DRIVE_ACCESS", "h-2": "", "1-0": "metadata", "1-1": "The metadata to be associated with the directory. It should be encoded as a base64 string.\n\nThis is an optional field. If not specified, it defaults to an empty string." }, "cols": 2, "rows": 2 } [/block] ### Response [block:code] { "codes": [ { "name": 200, "code": "Ok", "language": "json", "status": 200 }, { "code": "Unauthorized", "language": "http", "name": "401" }, { "code": "Fields are missing", "language": "http", "name": "400" } ], "sidebar": true } [/block] [block:api-header] { "type": "basic" } [/block] ## Examples [block:code] { "codes": [ { "code": "var request = require('request');\n\nvar endPoint = 'http://localhost:8100/nfs/directory/app/home/pics';\nvar payload = {\n isPrivate: true,\n metadata: new Buffer('sample metadata').toString('base64')\n};\n\nvar onResponse = function(err, response, body) {\n if (err) {\n return console.error(err.message);\n }\n if (response.statusCode === 401) {\n return console.error('Failed to authorise');\n }\n if (response.statusCode === 200) {\n return console.log('Directory created');\n }\n console.error('Failed to create directory.', body);\n};\n\nrequest.post(endPoint, {\n auth: {\n bearer: constants.token // pass the auth token\n },\n json: true,\n body: payload\n}, onResponse);\n", "language": "javascript", "name": "Nodejs" } ], "sidebar": true } [/block]