This repository was archived by the owner on Dec 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Files Resource
ashley williams edited this page Jun 12, 2015
·
1 revision
API Documentation
The File resource is represented in the database as such:
{
id: <Type.Integer.unique>
path: <Type.String.unique>
project_id: <Type.Integer> // The foreign key of the Project object the File belongs to
buffer: <Type.Blob> // The actual file data
}
Creates a new File object.
Expects a request.payload with the following attribtues:
-
path* -
project_id* buffer
* = required
Example:
{
path: `src/request-handler/index.js`,
project_id: 2,
buffer: [118,97,114,32,102,115,32,61,32,114,101,113,117,105...
}
Retrieves a collection of File objects.
Example response:
[
{
"id":1,
"project_id":1,
"path":"index.js",
"buffer":[118,97,114,32,102,115,32,61,32,114,101,113,117,105,...
},
{
"id":2,
"project_id":1,
"path":"package.json",
"buffer":[123,10,32,32,34,110,97,109,101,3...
}
]
Retrieves a single File object.
Example response:
// GET /files/1
{
"id":1,
"project_id":1,
"path":"index.js",
"buffer":[118,97,114,32,102,115,32,61,32,114,101,113,117,105,...
}
PUT /files/{id}
Updates a Project object based on its id attribute. The representation that is passed will replace the current representation of the object, so the full representation should be passed, alongside any changes.
Expects a request.payload containing:
pathproject_idbuffer
For example:
// PUT /files/7
{
path: `src/request-handler/new_file_name.js`,
project_id: 2,
buffer: [118,97,114,32,102,115,32,61,32,114,101,113,117,105...
}
DELETE /files/{id}
Deletes a File object based on its id attribute.