如何设计一个媒体分析引擎一个RESTful API [英] How to design a REStful API for a media analysis engine

查看:219
本文介绍了如何设计一个媒体分析引擎一个RESTful API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的宁静的概念,要设计一个简单的API为媒体分析服务,我需要建立,执行各种任务,例如脸分析,区域检测等对上传的图片和视频。

I am new to Restful concept and have to design a simple API for a media analysis service I need to set up, to perform various tasks, e.g. face analysis, region detection, etc. on uploaded images and video.

我最初的设计大纲如下:

Outline of my initial design is as follows:


  • 客户端员额配置XML文件 http://manalysis.com/facerecognition 。这将创建一个个人资料,可用于多种分析会议。响应XML包括提供ProfileID 引用此配置文件。客户可以跳过这一步使用默认的配置参数

  • 客户端的POST视频数据进行分析,以 http://manalysis.com/facerecognition (与提供ProfileID作为参数,如果它的设置)。这将创建一个分析会议。返回XML具有的SessionID

  • 客户端可以发送GET到 http://manalysis.com/facerecognition/SessionID 来接收会话的状态。

  • Client POSTs a configuration XML file to http://manalysis.com/facerecognition. This creates a profile that can be used for multiple analysis sessions. Response XML includes a ProfileID to refer to this profile. Clients can skip this step to use the default config parameters
  • Client POSTs video data to be analyzed to http://manalysis.com/facerecognition (with ProfileID as a parameter, if it's set up). This creates an analysis session. Return XML has the SessionID.
  • Client can send a GET to http://manalysis.com/facerecognition/SessionID to receive the status of the session.

我在正确的轨道上吗?具体来说,我有以下问题:

Am I on the right track? Specifically, I have the following questions:


  • 我应该包括 facerecognition 中的网址是什么?罗伊菲尔丁说:一个REST API一定不能定义固定的资源名称或层次结构这是错误的实例?

  • 的分析结果可以被返回到客户端在一个大的XML文件,或当检测到的每个事件。我该如何告诉分析引擎,其中返回的结果?

  • 我应该明确地删除文件时分析完成后,通过一个DELETE调用?

  • Should I include facerecognition in the URL? Roy Fielding says that "a REST API must not define fixed resource names or hierarchies" Is this an instance of that mistake?
  • The analysis results can either be returned to the client in one large XML file or when each event is detected. How should I tell the analysis engine where to return the results?
  • Should I explicitly delete a profile when analysis is done, through a DELETE call?

谢谢,

C

推荐答案

您可以修复入口点URL,

You can fix the entry point url,

GET /facerecognition

<FaceRecognitionService>
  <Profiles href="/facerecognition/profiles"/>
  <AnalysisRequests href="/facerecognition/analysisrequests"/>
</FaceRecognitionService>

张贴的XML配置文件的URL在情景元素的href属性创建一个新的配置文件

Create a new profile by posting the XML profile to the URL in the href attribute of the Profiles element

POST /facerecognition/profiles
201 - Created
Location: /facerecognition/profile/33

通过创建一个新的分析请求启动的分析。我会避免使用术语会话实在是太通用的,有很多负面的联想,在世界其它地区。

Initiate the analysis by creating a new Analysis Request. I would avoid using the term session as it is too generic and has lots of negative associations in the REST world.

POST /facerecognition/analysisrequests?profileId=33
201 - Created
Location: /facerecognition/analysisrequest/2103

检查进程的状态

GET /facerecognition/analysisrequest/2103

<AnalysisRequest>
   <Status>Processing</Status>
   <Cancel Method="DELETE" href="/facerecognition/analysisrequest/2103" />
</AnalysisRequest>

在加工完成后,同一GET可以返回

when the processing has finished, the same GET could return

<AnalysisRequest>
   <Status>Completed</Status>
   <Results href="/facerecognition/analysisrequest/2103/results" />
</AnalysisRequest>

这是我所选择的具体网址是比较乱,您可以使用什么是最清楚的给你。

The specific URLs that I have chosen are relatively arbitrary, you can use whatever is the clearest to you.

这篇关于如何设计一个媒体分析引擎一个RESTful API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆