PUT vs. POST for files upload RESTful api to be built using Zend Framework

前端 未结 4 1263
执念已碎
执念已碎 2020-12-12 12:45

I\'m building a RESTful api using Zend Framework via the Zend_Rest_Route. For files upload, should I use PUT or POST to handle the process? I\'m trying to be as consistent a

4条回答
  •  一向
    一向 (楼主)
    2020-12-12 13:45

    For file upload, unless it is replacing an existing resource, definitely use POST.

    In REST, POST is to create new resources, PUT to replace existing resources, GET to retrieve resources, and DELETE to delete resources.

    Source: http://en.wikipedia.org/wiki/Representational_state_transfer#RESTful_web_services

提交回复
热议问题