是否有人知道有任何样本可用于使用带有DotNetOpenAuth的oAuth上传文件并通过multipart / form-data提交?
答案 0 :(得分:0)
没有使用它的示例,但是这里是如何使用PostNetPartPart方法,DotNetOpenAuth v3.3中的新方法。
using DotNetOpenAuth.Messaging;
WebConsumer consumer; // you've initialized this
var endpoint = new MessageReceivingEndpoint(url, HttpDeliveryMethods.PostRequest | HttpDeliveryMethods. AuthorizationHeaderRequest);
IDirectWebRequestHandler requestHandler = consumer.Channel.WebRequestHandler;
var parts = new List<MultipartPostPart>();
parts.Add(MultipartPostPart.CreateFormPart("key", "value"));
parts.Add(MultipartPostPart.CreateFormFilePart("filefield", "c:\\temp\\foo.txt", "text/plain"));
HttpWebRequest req = consumer.PrepareAuthorizedRequest(endpoint, token);
IncomingWebResponse response = req.PostMultiPart(requestHandler, parts); // yes, it's an extension method