This describes all the API routes related to media resources.
There are two ways to create a new media: using a POST request or using spacebro.
Only media
and filename
fields are mandatory.
Example:
{
"media": "base64 string / path to a file / url",
"filename": "myNewMedia.jpg",
"bucketId" : "5678",
"details": {
"width": 600,
"height": 400,
"icon": {
"file": "icon.jpg",
"width": 64,
"height": 64,
"type": "image/jpg",
"path": "path to a file / url"
}
},
"meta": {
"foo": "bar"
}
}
A spacebro event mediaCreated
will be emitted.
media-manager awaits for mediaCreate
events.
Example:
{
"path": "path to a file / url",
"file": "myFile.jpg",
"type": "image/jpg",
"details": {
"width": 1024,
"height": 1024,
"thumbnail": {
"file": "myThumb.jpg",
"width": 128,
"height": 128,
"type": "image/jpg",
"path": "path to a file / url"
}
},
"meta": {
"put": "whatever",
"you": "want"
}
}
The details
and meta
object are copied, and media-manager will try to import files in the details
object if it finds a path or url (ex: if details.thumbnail.path
is defined and valid).
Returns a json object describing the media.
Example:
{
"_id": "58c90c689882891f79b79066",
"details": {
"width": 1024,
"height": 1024,
"thumbnail": {
"file": "thumb.jpg",
"width": 128,
"height": 128,
"type": "image/jpg",
"path": "/path/to/thumb.jpg",
"url": "http://media-manager.url/route/to/thumb"
}
},
"file": "media.gif",
"path": "path/to/media.gif",
"url": "http://media-manager.url/route/to/media",
"type": "image/gif",
"state": "public",
"uploadedAt": "2017-03-15T09:42:00.135Z",
"meta": {
"foo": "bar"
},
"__v": 0
}
Returns the media's raw data, image or video.
Returns the specified field from the media's json.
Example: GET /api/v1/medias/58c90c689882891f79b79066/path
"path/to/media.gif"
Use this route to modify state
and/or bucketId
fields of a media.
Example: PUT api/v1/medias/:id/?state=private&bucketId=098765
Use this route to modify the meta
object of a media.
Example:
{
"foo": "bar"
}
A spacebro event media-updated
will be emitted.
This route deletes the media instance from database and its associated file.
A spacebro event media-deleted
will be emitted.
Returns a json object describing the full set of media.
Returns the total amount of media in the database.
Returns the settings object used by media-manager.