Fork me on GitHub

Folders and files are referred, respectively, as: folder, and file. These resources make up the “Arquivos de Apoio” (Support Files) section, arranged in a Space, where you can save, organize, and download files.

Folder

It represents a folder in the file system, which can be in a folder and contain multiple folders and files. A space can have multiple folders.

Attributes

Attribute Description
ID Unique identifier of Folder
name Name
created_at Date of creation

Links

Link Description
self Folder in question
folder Folder which contains the folder in question (parent folder)
files Contained files
folders Contained folders
space Space where the folder is
user User who has created the folder

GET /api/folders/:id

Returns the folder in question.

Authorization

You must be enrolled in the course to which the folder belongs (in this case, the course of the space).

Parameters

Attribute Description Restrictions
id Folder ID N/A

Example

Request:
GET /api/folders/4

Response:

{
  "id" : 4,
    "name" : "My Folder",
    "created_at" "2012-01-13T12:11:22-02:00…",
    "links" : [
    {
      "href" : "http://www.redu.com.br/api/folders/4",
      "rel" : "self"
    },
    {
      "href" : "http://www.redu.com.br/api/folders/2",
      "rel" : "folder"
    },
    {
      "href" : "http://www.redu.com.br/api/folders/4/files",
      "rel" : "files"
    },
    {
      "href" : "http://www.redu.com.br/api/folders/4/folders",
      "rel" : "folders"
    },
    {
      "href" : "http://www.redu.com.br/api/spaces/1626",
      "rel" : "space"
    },
    {
      "href" : "http://www.redu.com.br/api/users/julianalucena",
      "rel" : "user"
    },
    ]
}

GET /api/folders/:folder_id/folders

Returns the folders in the folder in question.

Authorization

You must be enrolled in the course to which the folder belongs (in this case, the course of the space).

Parameters

Attribute Description Restrictions
id Parent folder ID N/A

GET /api/spaces/:space_id/folders

Returns the folders in the given space.

Authorization

You must be enrolled in the course to which the space belongs.

Parameters

Attribute Description Restrictions
id Space ID N/A

POST /api/folders/:id/folders

Creates new directory in the specified directory.

Authorization

You must be enrolled in the course to which the space belongs. And you need to be either administrator, professor/teacher or tutor on the course.

Parameters

Attribute Description Restrictions
folder[name] New name of file N/A

Example

The following example was created by using cURL.

curl \
  -H 'Authorization: OAuth us8Jsbsgbc3bb5b56nCuBFirbXni0LpQWI' \
  -H 'Content-type: application/json' \
  -X 'POST' \
  -d '{ "folder" : { "name" : "new folder" } }' \
  http://redu.com.br/api/folders/31/folders -vv

PUT /api/folders/:id

Updates name of a Folder.

Authorization

You must be enrolled in the course to which the space belongs. And you need to be either administrator, professor/teacher or tutor on the course.

Parameters

Attribute Description Restrictions
folder[name] New name of file N/A

DELETE /api/folders/:id

Deletes the specified folder.

Authorization

You must be enrolled in the course. And you need to be either administrator, professor/teacher or tutor on the course.

File

Represents a file in the file system, which is in a folder.

Attributes

Attribute Description
id Unique identifier of File
name Name
mimetype Format of file
size Size in megabytes
byte Size in bytes
created_at Date of creation

Links

Link Description
self File in question
folder Folder which contains the file (parent folder)
space Space where the folder is
user User who has created the file
raw Address of the raw file do be downloaded

GET /api/files/:id

Returns the file in question.

Authorization

You must be enrolled in the course to which the file belongs (in this case, the course of the space).

Parameters

Attribute Description Restrictions
id File ID N/A

Example

Request:
GET /api/files/4

Response:

{
  "id" : 4,
    "name" : "My File",
    "mimetype" : "application/pdf",
    "size" : "132Mb",
    "byte" : "12213",
    "created_at" "2012-01-13T12:11:22-02:00…",
    "links" : [
    {
      "href" : "http://www.redu.com.br/api/files/4",
      "rel" : "self"
    },
    {
      "href" : "http://www.redu.com.br/api/folders/2",
      "rel" : "folder"
    },
    {
      "href" : "http://www.redu.com.br/api/spaces/1626",
      "rel" : "space"
    },
    {
      "href" : "http://www.redu.com.br/api/users/julianalucena",
      "rel" : "user"
    },
    {
      "href" : "http://s3.amazonaws.com/redu_files/myfiles/attachments/309/original/01_intro.pdf?AWSAccessKeyId=AKIAIRKVQDTWT2NN4J4Q&Expires=1358789646&Signature=AoV34rkOyu9PFNxMxxAqQlDTBzA%3D",
      "rel" : "raw"
    },
    ]
}

GET /api/folders/:folder_id/files

Returns the files which are in the folder in question.

Authorization

You must be enrolled in the course to which the folder/file belongs (in this case, the course of the space).

Parameters

Attribute Description Restrictions
id Folder ID N/A

POST /api/folders/:folder_id/files

Creates a new file in the specified folder.

Authorization

You must be enrolled in the course. And you need to be either administrator, professor/teacher or tutor on the course.

Parameters

Attribute Description Restrictions
file[content] Binary data of the file to be created Maximum size of 100 Mb
Upload files

In cases of uploading a file, the following HTTP headers are required:

1. Content-Type: multipart/form-data
2. Content-Length: 13951 (size of file in bytes)

The usage of Content-type multipart/form-data makes possible that the HTTP request body is composed of multiple sets of data, where each one has its own Content-type. In this way, we can send the binary data of an image or PDF file, besides the name and type.

Example

The following example was created by using cURL.

curl \
  -H 'Authorization: OAuth us8JsbsgaH32jh3h23g32irbXni0LpQWI' \
  -F 'file[content]=@spec/fixtures/api/pdf_example.pdf;type=application/pdf' \
  http://redu.com.br/api/folders/31/files -vv

DELETE /api/files/:id

Deletes the specified file

Authorization

You must be enrolled in the course. And you need to be either administrator, professor/teacher or tutor on the course.