简体   繁体   English

最适合我的情况的Content-Type

[英]Most appropriate Content-Type for my case

I am just looking for the most appropriate way to indicate with HTTP POST my content type. 我只是在寻找最合适的方式来通过HTTP POST指示我的内容类型。

I have csv files. 我有csv文件。 They may have 1 line or they may have multiple lines. 他们可能有1行,也可能有多行。 As I am implementing the server side of this, distinguishing between the two can make my implementation a bit cleaner. 当我在实现服务器端时,区分两者可以使我的实现更加简洁。

text/cms+csv

Is what I have but that doesn't indicate how many entities exist in the payload. 这就是我所拥有的,但这并不表示有效负载中存在多少个实体。 Do I use a custom param? 我是否使用自定义参数?

There is no requirement to indicate the number of entities in a request payload. 不需要指出请求有效负载中的实体数。 If you are uploading multiple files in a single request, then each file in that request will have a corresponding entity. 如果要在单个请求中上传多个文件,则该请求中的每个文件将具有一个对应的实体。 Each entity in the request would then include its content-type, etc. This StackOverflow post shows an example. 然后,请求中的每个实体都将包括其内容类型等。此StackOverflow 帖子显示了一个示例。

If I understand your case correctly, you are uploading a single csv which may or may not have multiple lines. 如果我正确理解您的情况,则说明您正在上传单个csv,该csv可能有也可能没有多行。 There is no header that describes this. 没有描述此内容的标头。 The closest header to your case is arguably the Content-Length header. 与您的案例最接近的标头可以说是Content-Length标头。 This header indicates the size of an entity body. 此标头指示实体主体的大小。

To answer your question more directly, if you really need the line count, you might create a custom header. 为了更直接地回答您的问题,如果您确实需要行数,则可以创建一个自定义标题。 And as for an appropriate Content-Type, you should consider text/csv . 对于适当的Content-Type,您应该考虑text/csv

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM