接收大文件的 web API 的 http 请求方法
Which http request method for web API which receives big files
哪个http request method适合接收大文件?
我的用例:我想提供一个 HTTP API:
- 输入:mp3文件。整个文件(不仅仅是文件名)
- 输出:演唱这首歌的可能音乐翻译列表。
由于服务器上没有数据被修改,我认为 POST
和 PUT
不适合。
AFAIK 方法 GET
不适合:
- mp3 文件对于查询字符串来说太大。
- 在正文中包含数据的 GET 请求对我来说是新的。
Web API 接收大文件的 http 请求方法是什么?
更新
- 这不是上传。 mp3 是输入,一些文本是输出。
更新2
假设您想为 calculate_square_root()
提供 HTTP API。如果您输入 9
,您将收到 3
。你会用“上传”这个词代替数字 9
吗?普通GET和大GET之间的界限在哪里?
要将文件内容发送到服务器,您应该使用 POST
请求:
The POST
method requests that the target resource process the
representation enclosed in the request according to the resource's
own specific semantics. For example, POST
is used for the following
functions (among others):
- Providing a block of data, such as the fields entered into an HTML
form, to a data-handling process;
[...]
文件的内容将在请求的负载中发送,Content-Type
of the request should be set to multipart/form-data
。
要发送文件内容等大数据,您应该使用 POST 请求。
对于在服务器端上传文件,请求的 'Content-Type' 应该是 multipart/form-data。
引用自 RFC:HTTP 1.1 Method Definitions 这似乎是 POST。
The actual function performed by the POST method is determined by the server ...
The action performed by the POST method might not result in a resource that can be identified by a URI. ...
If a resource has been created on the origin server,...
最后两点似乎清楚地支持了服务器可以只处理数据而不存储任何东西的观点
哪个http request method适合接收大文件?
我的用例:我想提供一个 HTTP API:
- 输入:mp3文件。整个文件(不仅仅是文件名)
- 输出:演唱这首歌的可能音乐翻译列表。
由于服务器上没有数据被修改,我认为 POST
和 PUT
不适合。
AFAIK 方法 GET
不适合:
- mp3 文件对于查询字符串来说太大。
- 在正文中包含数据的 GET 请求对我来说是新的。
Web API 接收大文件的 http 请求方法是什么?
更新
- 这不是上传。 mp3 是输入,一些文本是输出。
更新2
假设您想为 calculate_square_root()
提供 HTTP API。如果您输入 9
,您将收到 3
。你会用“上传”这个词代替数字 9
吗?普通GET和大GET之间的界限在哪里?
要将文件内容发送到服务器,您应该使用 POST
请求:
The
POST
method requests that the target resource process the representation enclosed in the request according to the resource's own specific semantics. For example,POST
is used for the following functions (among others):
- Providing a block of data, such as the fields entered into an HTML form, to a data-handling process; [...]
文件的内容将在请求的负载中发送,Content-Type
of the request should be set to multipart/form-data
。
要发送文件内容等大数据,您应该使用 POST 请求。
对于在服务器端上传文件,请求的 'Content-Type' 应该是 multipart/form-data。
引用自 RFC:HTTP 1.1 Method Definitions 这似乎是 POST。
The actual function performed by the POST method is determined by the server ...
The action performed by the POST method might not result in a resource that can be identified by a URI. ...
If a resource has been created on the origin server,...
最后两点似乎清楚地支持了服务器可以只处理数据而不存储任何东西的观点