dongzao3923 2018-11-02 16:48
浏览 72

Symfony 4 - 上传文件的端点

I've developped an simple FileUploader Service based on the Symfony documentation found here:

My app is just a simple API called inside a Ionic Mobile App.

What I want to know is what is the best practices to give access to my uploaded images.

For exemple, I have an Sport entity App\Entity\Sport that stores an image: When i request GET /api/sports/ I want to send as response the full url to the image so it can be displayed inside the mobile app (e.g. http://symfony/api/public/uploads/sports/XXXXX.jpg)

Maybe I'm overcomplicating the issue but do I need to make an GET /public/uploads/sports/{id} as an endpoint to get my pictures ? because if possible i would like to have the pictures instantly available after the GET /api/sports and not having to query another time for the picture aswell

  • 写回答

1条回答 默认 最新

  • dongsutao8921 2018-11-02 16:54

    Why not just simply add the URL into a field of the JSON response object, where you can access the the picture directly? IMHO there is nothing wrong with that.

    I find a good reference to start with if it comes to these kind of decisions.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥20 被人匿名举报,可以反查吗
  • ¥15 华为ensp使用基本ACL限制公司网络访问
  • ¥15 帮我做下照片上的PLC题
  • ¥15 labview2022 使用modbus报缺少依赖?
  • ¥15 谷歌地图是不是不开通结算功能,api会使用不了哦
  • ¥15 unity腾讯云对象存储机型适配
  • ¥15 求全国交通咨询模拟代码,要求如下,可以完全在dev c++运行
  • ¥15 根据要求修改程序编码
  • ¥15 用 Python 做一个用 Excel 表导入的答题系统
  • ¥15 使用微信开发者工具实现一个“婚博会”小程序