Attachments API

creates file attachment from an word document 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: Yd4vyzMNyfKfxj9Cx2dkPE1uaCgwx8TzMQ
X-Api-Email: user-348@example.com

Route

POST /api/v1/attachments/

Body

{"attachable_id":44,"attachable_type":"Lecture","file":{"url":"https://www.filepicker.io/api/file/JStlBIc0QiathJfdClGp","filename":"test_Word.docx","mimetype":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","size":26371,"key":"If0gDJjNQ3ScDsPNvHR4_test_Word.docx","container":"lecture_attachments","path":"/uploads/test_Word.docx","isWriteable":true}}

cURL

curl "http://localhost:3000/api/v1/attachments/" -d '{"attachable_id":44,"attachable_type":"Lecture","file":{"url":"https://www.filepicker.io/api/file/JStlBIc0QiathJfdClGp","filename":"test_Word.docx","mimetype":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","size":26371,"key":"If0gDJjNQ3ScDsPNvHR4_test_Word.docx","container":"lecture_attachments","path":"/uploads/test_Word.docx","isWriteable":true}}' -X POST \
	-H "Accept: application/json" \
	-H "X-Api-Token: Yd4vyzMNyfKfxj9Cx2dkPE1uaCgwx8TzMQ" \
	-H "X-Api-Email: user-348@example.com" \
	-H "Content-Type: application/json" \
	-H "Host: school.worksonmy.computer"

Response

Headers

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

Status

201 Created

Body

{
  "created_at": "2019-10-31T22:01:13Z",
  "code_syntax": null,
  "content_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
  "audio_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
  "should_be_uploaded_to_wistia?": false,
  "data": null,
  "schema": null,
  "text_constructor": null,
  "full_url": "http://school.worksonmy.computer/courses/141/lectures/44",
  "url": "https://www.filepicker.io/api/file/JStlBIc0QiathJfdClGp",
  "host_id": null,
  "source": "user",
  "kind": "file",
  "name": "test_Word.docx",
  "host": "filepicker",
  "position": 1,
  "attachable_id": 44,
  "is_published": true,
  "downloadable": true,
  "text": null,
  "attachable_type": "Lecture",
  "thumbnail_url": null,
  "meta": {
    "class": "attachment",
    "url": null,
    "name": "test_Word.docx",
    "description": "",
    "image_url": null
  },
  "embeddable": false,
  "id": 27,
  "plain_text_html": ""
}