File 文件上载是';行不通
我试图在一个大摇大摆的界面上传一个文件,但它一直说找不到文件,不知道为什么,也许你们可以帮我:File 文件上载是';行不通,file,swagger,multipartform-data,form-data,File,Swagger,Multipartform Data,Form Data,我试图在一个大摇大摆的界面上传一个文件,但它一直说找不到文件,不知道为什么,也许你们可以帮我: /** * @SWG\Put( * path="/api/v1/profile/{id}/profilepicture", * tags={"Profile"}, * operationId="updateProfilePicture", * summary="updates the ProfilePicture",
/**
* @SWG\Put(
* path="/api/v1/profile/{id}/profilepicture",
* tags={"Profile"},
* operationId="updateProfilePicture",
* summary="updates the ProfilePicture",
* description="updates the ProfilePicture",
* consumes={"multipart/form-data"},
* produces={"application/json"},
* @SWG\Parameter(
* name="profilePicture",
* in="formData",
* description="Change the profilepicture",
* required=true,
* type="file",
* @SWG\Schema(ref="#definitions/Error"),
* ),
* @SWG\Response(
* response=200,
* description="Succeed!",
* ),
* @SWG\Response(
* response=405,
* description="Validation exception",
* ),
* )
* @param Request $request
* @return BinaryFileResponse
*/
public function updateProfilePicture(Request $request)
{
$profileId = $request->get('id');
/** @var UploadedFile $file */
$file = $request->files->get('profilePicture');
if($file == null)
{
throw new BadRequestHttpException('No file found!');
}
return (new BinaryFileResponse($file));
}
已尝试更改profilePicture的名称并清除缓存,但仍然存在相同的问题。不确定是否相关,但批注看起来不正确。文件参数不需要
@SWG\Schema
,并且您缺少路径参数id
的注释。将方法切换到Post可以解决此问题