文件上传无效

时间:2018-05-31 14:14:59

标签: file swagger multipartform-data form-data

我试图在SwaggerUI中上传文件,但它一直说没有找到文件,无法弄清楚原因,也许你们可以帮助我:

 /**
     * @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的名称并清除缓存,仍然存在同样的问题。

0 个答案:

没有答案