我正在上传PDF文件到node.js服务器,代码如下:
var file = new FileContentResult(...)
var client = new RestClient(_tenantOptions.BaseUrl + _tenantOptions.UploadPdfFilesUrn) {Timeout = _tenantOptions.RequestTimeoutMilliseconds};
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", accessToken);
request.AddFile("file", file.FileContents, file.ContentType);
var response = client.Execute<UploadFileResponse>(request);
此文件与filename.undefined
到file.ContentType = "application/pdf"
一样出现在服务器上。我错过了什么?
根据RestSharp的源代码,AddFile
的4参数形式也接受文件名。
尝试
request.AddFile("file", file.FileContents, "document.pdf", file.ContentType);