Attachments API

creates audio attachment from an mp3 file

POST /api/v1/attachments/

Parameters

Name Description
attachable_id the id of the object this should be attached to (Lecture/Course)
attachable_type type of the object (Lecture/Course)
file a filepicker file blob {url:, filename:, mimetype:, size:, key:,container:}
text the contents of a text/html attachment
text_constructor_attributes text constructor attributes

Request

Headers

Accept: application/json
X-Api-Token: Cc2CFkcunLwpdt6ss2fzy5WbjMwQCEms6A
X-Api-Email: user-342@example.com

Route

POST /api/v1/attachments/

Body

{"attachable_id":41,"attachable_type":"Lecture","file":{"url":"https://www.filepicker.io/api/file/ZGl5zYJKSZuYOKDeiaqI","filename":"conclusion.mp3","mimetype":"audio/mpeg","size":2682458,"key":"mHpmty8tTDqIk7NUIctS_conclusion.mp3","container":"lecture_attachments","path":"/uploads/conclusion.mp3","isWriteable":true}}

cURL

curl "http://localhost:3000/api/v1/attachments/" -d '{"attachable_id":41,"attachable_type":"Lecture","file":{"url":"https://www.filepicker.io/api/file/ZGl5zYJKSZuYOKDeiaqI","filename":"conclusion.mp3","mimetype":"audio/mpeg","size":2682458,"key":"mHpmty8tTDqIk7NUIctS_conclusion.mp3","container":"lecture_attachments","path":"/uploads/conclusion.mp3","isWriteable":true}}' -X POST \
	-H "Accept: application/json" \
	-H "X-Api-Token: Cc2CFkcunLwpdt6ss2fzy5WbjMwQCEms6A" \
	-H "X-Api-Email: user-342@example.com" \
	-H "Content-Type: application/json" \
	-H "Host: school.worksonmy.computer"

Response

Headers

Content-Type: application/json; charset=utf-8
Content-Length: 702

Status

201 Created

Body

{
  "created_at": "2019-10-31T22:01:10Z",
  "code_syntax": null,
  "content_type": "audio/mpeg",
  "audio_type": "audio/mpeg",
  "should_be_uploaded_to_wistia?": false,
  "data": null,
  "schema": null,
  "text_constructor": null,
  "full_url": "http://school.worksonmy.computer/courses/138/lectures/41",
  "url": "https://www.filepicker.io/api/file/ZGl5zYJKSZuYOKDeiaqI",
  "host_id": null,
  "source": "user",
  "kind": "audio",
  "name": "conclusion.mp3",
  "host": "filepicker",
  "position": 1,
  "attachable_id": 41,
  "is_published": true,
  "downloadable": false,
  "text": null,
  "attachable_type": "Lecture",
  "thumbnail_url": null,
  "meta": {
    "class": "attachment",
    "url": null,
    "name": "conclusion.mp3",
    "description": "",
    "image_url": null
  },
  "embeddable": true,
  "id": 24,
  "plain_text_html": ""
}