0
我有一個ASP.Net HttpClient POST請求的問題。 事實上,我想使用SolrCell在Solr中索引文檔。我用捲髮這樣的:Httpclient asp.net核心捲曲等效
curl 'http://localhost:8983/solr/my_collection/update/extract?literal.id=doc1&commit=true' -F "[email protected]/exampledocs/solr-word.pdf"
不幸的是我只能將文件發送爲多部分文件上傳(與HttpClient的),這樣,我需要確定該文件的MIME類型,我做到了但我仍然遇到DOCX和PPTX文件的錯誤。
這裏是我的代碼:
var fileBytes = File.ReadAllBytes(path);
requestContent.Add(new ByteArrayContent(fileBytes), "file");
requestContent.Headers.Remove("Content-Type");
requestContent.Headers.Add("Content-Type", contentType);
var response = await client.PostAsync(defaultSolrUri, requestContent);
return response.Content;
請幫助。
這裏有什麼'contentType'變量的值? –
application/vnd.openxmlformats-officedocument.presentationml.presentation –
文件擴展名:pptx Mime-Type:application/vnd.openxmlformats-officedocument.presentationml.presentation –