2017 © Pedro Peláez
 

symfony-bundle media-api-bundle

Api to upload files.

image

saro0h/media-api-bundle

Api to upload files.

  • Monday, October 19, 2015
  • by saro0h
  • Repository
  • 2 Watchers
  • 12 Stars
  • 47 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Saro0h\MediaApiBundle

SensioLabsInsight, (*1)

This bundle allows you to have an upload of files through an API., (*2)

Installation

Step 1: Install MediaApiBundle using Composer

Add MediaApiBundle in your composer.json:, (*3)

{
    "require": {
        "saro0h/media-api-bundle": "~1.0"
    }
}

Now tell composer to download the bundle by running the command:, (*4)

$ php composer.phar update saro0h/media-api-bundle

Step 2: Enable the bundle

Enable the bundle in the kernel:, (*5)

<?php

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Saro0h\MediaApiBundle\MediaApiBundle(),
        // ...
    );
}

Step 3: Import the routes of the bundle

Add the following lines to the app/config/routing.yml:, (*6)

media_api_bundle:
    resource: "@MediaApiBundle/Resources/config/routing.yml"

Step 4: Create the database and the schema

Run the following commands (after configuring the ORM parameters), (*7)

app/console doctrine:database:create
app/console doctrine:schema:create

Step 4 (optional): Configure your config.yml file

# app/config/config.yml
media_api:
    media_path: %media_path%    # Path to the folder where the media will be uploaded (by default it's `web/uploads` folder of your project)
    field_name: %filename%      # Name of the field used to supply the file in the form (by default it's "media")

Usage

Upload a file

  • POST /media

If you did not configure the bundle, you just have to POST on the url /media/api/upload the field mediawith the file as showed below: upload, (*8)

If you can also choose the name of the file uploaded by supplying the field filename: upload_with_filename, (*9)

Get a media

  • GET /media/api/{id}

get_media, (*10)

Delete a media

  • DELETE /media/api/get/{id}

delete_media, (*11)

License

This bundle is licensed under the MIT license., (*12)

The Versions