2017 © Pedro Pelรกez
 

library media

image

optimuscms/media

  • Thursday, July 12, 2018
  • by optimuscms
  • Repository
  • 1 Watchers
  • 0 Stars
  • 29 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Media

This package provides the core backend functionality within the CMS to upload media (image) files and organise them into folders., (*1)

Installation

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,
    ...
];

API Routes

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)

, (*8)

List folders

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"
    }
]

, (*12)

Get folder

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"
}

, (*16)

Update folder

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"
}

, (*20)

Create folder

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"
}

, (*24)

Delete folder

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)

, (*29)

List media items

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"
    }
]

, (*33)

Get media item

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"
}

, (*37)

Update media item

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"
}

, (*41)

Create media item

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"
}

, (*45)

Delete media item

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)

License

The MIT License (MIT). Please see License File for more information., (*50)

The Versions

12/07 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

by Jack Robertson