dart-io

How can I upload a PDF using Dart's HttpClient?

有些话、适合烂在心里 提交于 2019-11-27 02:56:39
问题 I need to post a PDF file to a remote REST API, and I can't for the life of me figure it out. No matter what I do, the server responds that I have not yet associated an object with the file parameter. Let's say that I have a PDF called test.pdf . This is what I've been doing so far: // Using an HttpClientRequest named req req.headers.contentType = new ContentType('application', 'x-www-form-urlencoded'); StringBuffer sb = new StringBuffer(); String fileData = new File('Test.pdf')