Git Product home page Git Product logo

mediaapibundle's Introduction

Saro0h\MediaApiBundle

SensioLabsInsight

This bundle allows you to have an upload of files through an API.

Installation

Step 1: Install MediaApiBundle using Composer

Add MediaApiBundle in your composer.json:

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

Now tell composer to download the bundle by running the command:

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

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?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:

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)

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

If you can also choose the name of the file uploaded by supplying the field filename: upload_with_filename

Get a media

  • GET /media/api/{id}

get_media

Delete a media

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

delete_media

License

This bundle is licensed under the MIT license.

mediaapibundle's People

Contributors

saro0h avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mediaapibundle's Issues

Improve code

  • Change the name of the controller
  • Replace config of routing in yaml
  • Add a prefix for routes in the bundle
  • Add some hypermedia links
  • Make a SensioLabs Insight analysis

mimimum stability of (dev)dependencies

quand j'installe ton bundle, j'ai cette erreur

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for saro0h/media-api-bundle ~1.0 -> satisfiable by saro0h/media-api-bundle[1.0].
- saro0h/media-api-bundle 1.0 requires willdurand/hateoas-bundle 1.0.*@dev -> no matching package found.

Potential causes:

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.