Symfony图片下载

时间:2015-07-23 14:51:49

标签: php symfony amazon-s3 doctrine-orm

我有动作下载图片和帖子图片toamazonS3并在DB中设置url AmazonS3:

public function photoUploadAction($username)
{
    $em = $this->getDoctrine()->getManager();
    $request = $this->get('request');
    $profileRepository = $this->get('artel.profile.developer.repository');
    $developer = $profileRepository->findOneByUsername($username);
    $developer_username = $developer->getUserName();

    if (!$developer) {
        throw $this->createNotFoundException('Unable to find a profile.');
    }
    $authenticator = $this->get('artel.profile.authenticator');
    if (!$authenticator->check($developer)) {
        throw new AccessDeniedException('Access Denied!');
    }

    $url = sprintf(
        '%s%s',
        $this->container->getParameter('acme_storage.amazon_s3.base_url'),
        $this->getPhotoUploader()->upload($request->files->get('file'), $developer_username)
    );

    $developer->setImage($url);
    $em->persist($developer);

    $em->flush();

    return new Response($url);

我需要,如果这张照片的尺寸为1024x768或更大,我必须改变与宽度150成比例的一个尺寸高度。我是怎么做到的。有什么方法可以解决这个问题?

0 个答案:

没有答案