<?php

namespace LM\Bundle\CoreBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class AppController extends Controller
{
    /**
     * Upload Image to S3
     *
     * @param string $name Image field name
     * @param int $maxWidth Maximum thumb width
     * @param int $maxHeight Maximum thumb height
     *
     * @return string
     */
    protected function uploadImage($name, $maxWidth = 100, $maxHeight = 100)
    {
        $image = $this->getRequest()->files->get($name);

        $uploader = $this->get('core_storage.photo_uploader');
        $uploadedUrl = $uploader->upload($image);

        return $this->container->getParameter('amazon_s3_base_url') . $uploadedUrl;
    }
}