我已编写以下代码让我的Symfony后端返回图片:
/**
* @Route("/project/{id}/image", methods={"GET"}, name="get_project_image")
*/
public function getImage($id) {
$repository = $this->getDoctrine()->getRepository(Project::class);
$project = $repository->find($id);
$filePath = $this->getParameter('project_image_directory').$project->getImage();
return new BinaryFileResponse($filePath);
}
此图片也位于我的公共目录中,因此可通过以下网址访问:http://192.168.1.128:8000/uploads/project/5f5d8575ebd98fa7fa970ad2d910314f.jpeg
当我在浏览器中打开图片时,两个网址都会返回图片,但是,只有第二个图片显示在我的React Native应用程序中...