dongpenggan6812 2019-03-30 14:39
浏览 28

使用Vich从guzzle上传图像响应到控制器Symfony

I try to make image fixtures using a library online => with the response i want to upload the photo into a field.

I use Symfony 3.4 with the environment php7.1. I have alreagy make the request to the libraty online, with the response Iwant to use it to upload the image.

My Controller

/**
     * @Route("/", name="homepage")
     */
    public function indexAction(Request $request)
    {
        $requestManager = $this->get('request_manager');
        $data = $requestManager->sendRequest('https://source.unsplash.com/100x100/?usa');
die;

    }
}

I want to use the response data to put it into a UploadedFile, why ? in order to use it to upload my file with vich ... for exemple I will do something like that:

$entity = new Person();
$entity->setAvatarFile($dataUploadedFile)

Actually I can't put the data into a new uploadedFile() because the response binary ... I really don't know if it possible ... ut if it's possible it could be crazy as f*k :D. I want do that to make some fixtures for each entity which need an image ... Thanks for any Help.

Sorry for my bad english :).

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)