问题描述
我正在尝试使用vichUploader和api平台更新上传的文件。
所以我正在这样做:
MediaObject entity
itemOperations={
* "get",* "put"={
* "controller"=EditAvatarController::class,* "deserialize"=false,* "method"= "POST",* "security"="is_granted('ROLE_USER') and object.user == user",* "validation_groups"={"Default","media_object_update"},* "openapi_context"={
* "requestBody"={
* "content"={
* "multipart/form-data"={
* "schema"={
* "type"="object",* "properties"={
* "file"={
* "type"="string",* "format"="binary"
* }
* }
* }
* }
* }
* }
* }
* },* }
MediaUpdate控制器
$webPath = $this->parameterBag->get('kernel.project_dir') . '/public/media/avatars/' . $file->getFilePath();
unlink($webPath);
$uploadedFile = $request->files->get('file');
if (!$uploadedFile) {
throw new BadRequestHttpException('"file" is required');
}
$file->file = $uploadedFile;
return $file;
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)