1
想象一下,我正在創建一個API以允許用戶將圖像附加到其配置文件中,其中圖像可能來自正文中的二進制提交或服務器將檢索並處理的url 。針對不同機制的RESTful語義
假設API期望用二進制圖象數據的PUT到
/user/jon/image
當添加的URL的功能,其下面的將是優選的?
A:
PUT to /user/jon/image/url
passing the url in the body
或
B:
PUT /user/jon/image/
passing in a url in the body and setting a MIME type to advise the host whether or not the content is an image or an URL?
是否有處理這種情況的一個標準呢?我覺得利用MIME類型來決定的有效載荷是語義上更正確的,但少一點發現
感謝
什麼是你的問題 – 2014-09-29 09:40:23
修正 - 我想知道什麼是允許API從不同來源獲得相同信息的最佳方案。我有點難以理解這個問題的簡潔標題 – 2014-09-29 10:32:23
你打算從url中檢索圖片還是隻在指定位置使用圖片? – Leon 2014-09-29 10:42:12