Skip to main content

API / Media

MethodEndpointDescription
GET/api/mediaGets an uploaded media file.
POST/api/mediaUploads a media file.
DELETE/api/media/:media_idDeletes uploaded media files.

GET /api/media

Gets an uploaded media file.

Example Request
curl -u "username:username" -X GET 'http://localhost:9000/api/media' \
--header 'Content-Type: multipart/form-data; boundary=--------------------------093715978792575906250298'
Example Response
{
"data": [
{
"id": 1,
"uuid": "ec7b45ce-1408-4e5c-924e-965326a20287",
"filename": "Media file",
"created_at": "2020-04-08T22:43:45.080058+01:00",
"thumb_url": "/uploads/image_thumb.jpg",
"uri": "/uploads/image.jpg"
}
]
}

Response definitions The following table describes each item in the response.

Response itemDescriptionData type
dataArray of the media file objects, which contains an information about the uploaded media filesarray
idMedia file object IDnumber (int)
uuidMedia file uuidstring (uuid)
filenameName of the media filestring
created_atDate and time, when the media file object was createdString (localDateTime)
thumb_uriThe thumbnail URI of the media filestring
uriURI of the media filestring

POST /api/media

Uploads a media file.

Parameters
NameParameter TypeData TypeRequired/OptionalDescription
fileRequest bodyMedia fileRequiredThe media file to be uploaded.
Example Request
curl -u "username:username" -X POST 'http://localhost:9000/api/media' \
--header 'Content-Type: multipart/form-data; boundary=--------------------------183679989870526937212428' \
--form 'file=@/path/to/image.jpg'
Example Response
{
"data": {
"id": 1,
"uuid": "ec7b45ce-1408-4e5c-924e-965326a20287",
"filename": "Media file",
"created_at": "2020-04-08T22:43:45.080058+01:00",
"thumb_uri": "/uploads/image_thumb.jpg",
"uri": "/uploads/image.jpg"
}
}

Response definitions

Response itemDescriptionData type
dataTrue means that the media file was successfully uploadedboolean

DELETE /api/media/:media_id

Deletes an uploaded media file.

Parameters
NameParameter TypeData TypeRequired/OptionalDescription
Media_idPath ParameterNumberRequiredThe id of the media file you want to delete.
Example Request
curl -u "username:username" -X DELETE 'http://localhost:9000/api/media/1'
Example Response
{
"data": true
}

Response definitions

Response itemDescriptionData type
dataTrue means that the media file was successfully deletedboolean