資源簡介
WCF 是微軟力推的通訊框架,它能夠以 ASP.NET WebService 的方式實現 RESTful 方式的服務。但是缺陷是目前的版本不支持對 HTTP multipart 格式的自動解析。而不像傳統的 ASP.NET WebService 可以自動解析 multipart 中的多媒體數據,并通過訪問 Context.Request.Form["name"] 和 Context.Request.Files["name"] 方便地訪問。
這份代碼在 HttpMultipartFormDataParser (https://github.com/Vodurden/Http-Multipart-Data-Parser) 的基礎上,解決了中文亂碼的問題。希望給和我一樣曾經被這個問題困擾的朋友一些幫助。
關于代碼的使用方式,請參見 Vodurden 在 GitHub 上的說明。
代碼片段和文件信息
//?--------------------------------------------------------------------------------------------------------------------
//?
//???Copyright?(c)?2013?Jake?Woods
//???
//???Permission?is?hereby?granted?free?of?charge?to?any?person?obtaining?a?copy?of?this?software?
//???and?associated?documentation?files?(the?“Software“)?to?deal?in?the?Software?without?restriction?
//???including?without?limitation?the?rights?to?use?copy?modify?merge?publish?distribute?
//???sublicense?and/or?sell?copies?of?the?Software?and?to?permit?persons?to?whom?the?Software?
//???is?furnished?to?do?so?subject?to?the?following?conditions:
//???
//???The?above?copyright?notice?and?this?permission?notice?shall?be?included?in?all?copies?
//???or?substantial?portions?of?the?Software.
//???
//???THE?SOFTWARE?IS?PROVIDED?“AS?IS“?WITHOUT?WARRANTY?OF?ANY?KIND?EXPRESS?OR?IMPLIED?
//???INCLUDING?BUT?NOT?LIMITED?TO?THE?WARRANTIES?OF?MERCHANTABILITY?FITNESS?FOR?A?PARTICULAR?
//???PURPOSE?AND?NONINFRINGEMENT.?IN?NO?EVENT?SHALL?THE?AUTHORS?OR?COPYRIGHT?HOLDERS?BE?LIABLE?FOR?
//???ANY?CLAIM?DAMAGES?OR?OTHER?LIABILITY?WHETHER?IN?AN?ACTION?OF?CONTRACT?TORT?OR?OTHERWISE?
//???ARISING?FROM?OUT?OF?OR?IN?CONNECTION?WITH?THE?SOFTWARE?OR?THE?USE?OR?OTHER?DEALINGS?IN?THE?SOFTWARE.
//?
//?Jake?Woods
//?
//???Provides?character?based?and?byte?based?stream-like?read?operations?over?multiple
//???streams?and?provides?methods?to?add?data?to?the?front?of?the?buffer.
//?
//?--------------------------------------------------------------------------------------------------------------------
namespace?Wenhe.Foundation.Web.HttpMultipart
{
????using?System;
????using?System.Collections.Generic;
????using?System.IO;
????using?System.Linq;
????using?System.Text;
????///?
????///?????Provides?character?based?and?byte?based?stream-like?read?operations?over?multiple
????///?????streams?and?provides?methods?to?add?data?to?the?front?of?the?buffer.
????///?
????internal?class?BinaryStreamStack
????{
????????#region?Fields
????????///?
????????///?????Holds?the?streams?to?read?from?the?stream?on?the?top?of?the
????????///?????stack?will?be?read?first.
????????///?
????????private?readonly?Stack?streams?=?new?Stack();
????????#endregion
????????#region?Constructors?and?Destructors
????????///?
????????///?????Initializes?a?new?instance?of?the? ?class?with?the?default
????????///?????encoding?of?UTF8.
????????///?
????????public?BinaryStreamStack()
????????????:?this(Encoding.UTF8)
????????{
????????}
????????///?
????????///?Initializes?a?new?instance?of?the? ?class.
????????///?
????????///?
????????///?The?encoding?to?use?for?character?based?operations.
????????///?
????????public?BinaryStreamSt
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????14578??2013-02-18?22:55??BinaryStreamStack.cs
?????文件????????4209??2013-02-18?14:10??FilePart.cs
?????文件????????2272??2013-02-18?14:10??MultipartParseException.cs
?????文件???????30721??2013-02-18?22:57??MultipartParser.cs
?????文件????????2776??2013-02-18?14:10??ParameterPart.cs
?????文件???????13199??2013-02-18?21:22??RebufferableBinaryReader.cs
?????文件????????4834??2013-02-18?14:10??SubsequenceFinder.cs
評論
共有 條評論