dev-master
9999999-dev
MIT
The Requires
by Jack Robertson
This package provides the core backend functionality within the CMS to upload media (image) files and organise them into folders., (*1)
This package can be installed through Composer., (*2)
composer require optimuscms/media
In Laravel 5.5 and above the package will autoregister the service provider., (*3)
In Laravel 5.4 you must install this service provider:, (*4)
// config/app.php 'providers' => [ ... Optimus\Media\MediaServiceProvider::class, ... ];
The API follows standard RESTful conventions, with responses being returned in JSON. Appropriate HTTP status codes are provided, and these should be used to check the outcome of an operation., (*5)
Folders - List folders - Get folder - Create folder - Update folder - Delete folder, (*6)
Media Items - List media items - Get media item - Create media item - Update media item - Delete media item, (*7)
GET /admin/api/media-folders
List all available folders that media items can be added to., (*9)
Parameters, (*10)
Parameter | Required? | Type | Description |
---|---|---|---|
parent | โ | int | A folder ID. When provided will only show folders nested inside this folder. |
Example Response, (*11)
[ { "id": 12, "parent_id": null, "name": "Product Images", "created_at": "2017-12-24 09:36:23", "updated_at": "2017-12-25 10:15:12" }, { "id": 13, "parent_id": 12, "name": "Product Thumbnails", "created_at": "2019-02-19 09:36:23", "updated_at": "2019-02-19 09:36:23" } ]
GET /admin/api/media-folders/{id}
Retrieve details for a specific folder., (*13)
Parameters, (*14)
Parameter | Required? | Type | Description |
---|---|---|---|
id | โ | int | The ID of the folder |
Example Response, (*15)
{ "id": 12, "parent_id": null, "name": "Product Images", "created_at": "2017-12-24 09:36:23", "updated_at": "2017-12-25 10:15:12" }
PUT/PATCH /admin/api/media-folders/{id}
Update the details of a folder., (*17)
Parameters, (*18)
Parameter | Required? | Type | Description |
---|---|---|---|
parent_id | โ | int | The ID of the parent folder. Set to empty to move the folder into the root |
name | โ | string | The name of the folder |
Example Response, (*19)
{ "id": 12, "parent_id": null, "name": "Product Images", "created_at": "2017-12-24 09:36:23", "updated_at": "2017-12-25 10:15:12" }
POST /admin/api/media-folders
Create a new folder., (*21)
Parameters, (*22)
Parameter | Required? | Type | Description |
---|---|---|---|
parent_id | โ | int | The ID of the parent folder. Set to null to move the folder into the root |
name | โ | string | The name of the folder |
Example Response, (*23)
{ "id": 12, "parent_id": null, "name": "Product Images", "created_at": "2017-12-24 09:36:23", "updated_at": "2017-12-25 10:15:12" }
DELETE /admin/api/media-folders/{id}
Delete a folder., (*25)
Parameters, (*26)
Parameter | Required? | Type | Description |
---|---|---|---|
id | โ | int | The ID of the folder |
Example Response, (*27)
The HTTP status code will be 204 if successful., (*28)
GET /admin/api/media
List available media items., (*30)
Parameters, (*31)
Parameter | Required? | Type | Description |
---|---|---|---|
folder | โ | int | Folder ID. When provided will only show media items from this folder. |
Example Response, (*32)
[ { "id": 356, "folder_id": 12, "name": "My Image", "file_name": "my_image.jpg", "disk": "local", "mime_type": "image/jpeg", "size": 102400, "created_at": "2017-12-24 09:36:23", "updated_at": "2017-12-25 10:15:12" }, { "id": 513, "folder_id": 4, "name": "Landscape", "file_name": "landscape.png", "disk": "local", "mime_type": "image/png", "size": 219462, "created_at": "2019-02-19 09:36:23", "updated_at": "2019-02-19 09:36:23" } ]
GET /admin/api/media/{id}
Retrieve details of a specific media item., (*34)
Parameters, (*35)
Parameter | Required? | Type | Description |
---|---|---|---|
id | โ | int | The ID of the media item |
Example Response, (*36)
{ "id": 513, "folder_id": 4, "name": "Landscape", "file_name": "landscape.png", "disk": "local", "mime_type": "image/png", "size": 219462, "created_at": "2019-02-19 09:36:23", "updated_at": "2019-02-19 09:36:23" }
PUT/PATCH /admin/api/media/{id}
Update the details of a single media item., (*38)
Parameters, (*39)
Parameter | Required? | Type | Description |
---|---|---|---|
name | โ | string | A user-facing name for the media item |
folder_id | โ | int | The ID of the folder in which to store the media. If an empty value is provided, the media will be moved into the root folder. |
Example Response, (*40)
{ "id": 513, "folder_id": 4, "name": "Landscape", "file_name": "landscape.png", "disk": "local", "mime_type": "image/png", "size": 219462, "created_at": "2019-02-19 09:36:23", "updated_at": "2019-02-19 09:36:23" }
POST /admin/api/media
Create and store a new media item., (*42)
Parameters, (*43)
Parameter | Required? | Type | Description |
---|---|---|---|
file | โ | file | The file that is being uploaded |
folder_id | โ | int | The ID of the folder in which to store the media. If not provided, the media will be stored in the root folder. |
Example Response, (*44)
{ "id": 513, "folder_id": 4, "name": "Landscape", "file_name": "landscape.png", "disk": "local", "mime_type": "image/png", "size": 219462, "created_at": "2019-02-19 09:36:23", "updated_at": "2019-02-19 09:36:23" }
DELETE /admin/api/media/{id}
Delete a media item., (*46)
Parameters, (*47)
Parameter | Required? | Type | Description |
---|---|---|---|
id | โ | int | The ID of the media item to delete |
Example Response, (*48)
The HTTP status code will be 204 if successful., (*49)
The MIT License (MIT). Please see License File for more information., (*50)
MIT