Attachments API

creates image attachment from an image 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: dRxhchfz7ybpXpj6QGgex6m1m8_N6aV6dg
X-Api-Email: user-346@example.com

Route

POST /api/v1/attachments/

Body

{"attachable_id":43,"attachable_type":"Lecture","file":{"url":"https://www.filepicker.io/api/file/uUHSFsLnRL8Zd8t3dMQA","filename":"test_image.png","mimetype":"image/png","size":413743,"key":"Xwg61ToMS0ORdnrtAd8w_test_image.png","container":"lecture_attachments","path":"/uploads/test_image.png","isWriteable":true}}

cURL

curl "http://localhost:3000/api/v1/attachments/" -d '{"attachable_id":43,"attachable_type":"Lecture","file":{"url":"https://www.filepicker.io/api/file/uUHSFsLnRL8Zd8t3dMQA","filename":"test_image.png","mimetype":"image/png","size":413743,"key":"Xwg61ToMS0ORdnrtAd8w_test_image.png","container":"lecture_attachments","path":"/uploads/test_image.png","isWriteable":true}}' -X POST \
	-H "Accept: application/json" \
	-H "X-Api-Token: dRxhchfz7ybpXpj6QGgex6m1m8_N6aV6dg" \
	-H "X-Api-Email: user-346@example.com" \
	-H "Content-Type: application/json" \
	-H "Host: school.worksonmy.computer"

Response

Headers

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

Status

201 Created

Body

{
  "created_at": "2019-10-31T22:01:12Z",
  "code_syntax": null,
  "content_type": "image/png",
  "audio_type": "image/png",
  "should_be_uploaded_to_wistia?": false,
  "data": null,
  "schema": null,
  "text_constructor": null,
  "full_url": "http://school.worksonmy.computer/courses/140/lectures/43",
  "url": "https://www.filepicker.io/api/file/uUHSFsLnRL8Zd8t3dMQA",
  "host_id": null,
  "source": "user",
  "kind": "image",
  "name": "test_image.png",
  "host": "filepicker",
  "position": 1,
  "attachable_id": 43,
  "is_published": true,
  "downloadable": false,
  "text": null,
  "attachable_type": "Lecture",
  "thumbnail_url": null,
  "meta": {
    "class": "attachment",
    "url": null,
    "name": "test_image.png",
    "description": "",
    "image_url": null
  },
  "embeddable": true,
  "id": 26,
  "plain_text_html": ""
}