C# Class norvanco.http.MultipartForm

Allow the transfer of data files using the W3C's specification for HTTP multipart form data. Microsoft's version has a bug where it does not format the ending boundary correctly. Written by: [email protected]
ファイルを表示 Open project: NGFieldScope/JS-FieldScope

Protected Properties

Property Type Description
coRequest System.Net.HttpWebRequest

Public Methods

Method Description
MultipartForm ( string url ) : System

Initialize our class for use to send data files.

getFileheader ( string aFilename ) : string

Returns the proper content information for the file we are sending.

Hits Patel reported a bug when used with ActiveFile. Added semicolon after sendfile to resolve that issue. Tested for compatibility with IIS 5.0 and Java.

getFiletrailer ( ) : string

Creates the proper ending boundary for the multipart upload.

getFormfields ( ) : string

Builds the proper format of the multipart data that contains the form fields and their respective values.

getResponse ( ) : void

Here we actually make the request to the web server and retrieve it's response into a text buffer.

getStream ( ) : Stream

Determines if we have a file stream set, and returns either the HttpWebRequest stream of the file.

sendFile ( string aFilename, CookieContainer cookies ) : void

Transmits a file to the web server stated in the URL property. You may call this several times and it will use the values previously set for fields and URL.

sendFile ( string aFilename, Stream readIn, CookieContainer cookies ) : void
sendFile ( string aFilename, byte data, CookieContainer cookies ) : void
setField ( string key, string str ) : void

Allows you to add some additional field data to be sent along with the transfer. This is usually used for things like userid and password to validate the transfer.

setFilename ( string path ) : void

Used to signal we want the output to go to a text file verses being transfered to a URL.

writeString ( System io, string str ) : void

Mainly used to turn the string into a byte buffer and then write it to our IO stream.

Method Details

MultipartForm() public method

Initialize our class for use to send data files.
public MultipartForm ( string url ) : System
url string The web address of the recipient of the data transfer.
return System

getFileheader() public method

Returns the proper content information for the file we are sending.
Hits Patel reported a bug when used with ActiveFile. Added semicolon after sendfile to resolve that issue. Tested for compatibility with IIS 5.0 and Java.
public getFileheader ( string aFilename ) : string
aFilename string
return string

getFiletrailer() public method

Creates the proper ending boundary for the multipart upload.
public getFiletrailer ( ) : string
return string

getFormfields() public method

Builds the proper format of the multipart data that contains the form fields and their respective values.
public getFormfields ( ) : string
return string

getResponse() public method

Here we actually make the request to the web server and retrieve it's response into a text buffer.
public getResponse ( ) : void
return void

getStream() public method

Determines if we have a file stream set, and returns either the HttpWebRequest stream of the file.
public getStream ( ) : Stream
return System.IO.Stream

sendFile() public method

Transmits a file to the web server stated in the URL property. You may call this several times and it will use the values previously set for fields and URL.
public sendFile ( string aFilename, CookieContainer cookies ) : void
aFilename string The full path of file being transfered.
cookies System.Net.CookieContainer
return void

sendFile() public method

public sendFile ( string aFilename, Stream readIn, CookieContainer cookies ) : void
aFilename string
readIn Stream
cookies System.Net.CookieContainer
return void

sendFile() public method

public sendFile ( string aFilename, byte data, CookieContainer cookies ) : void
aFilename string
data byte
cookies System.Net.CookieContainer
return void

setField() public method

Allows you to add some additional field data to be sent along with the transfer. This is usually used for things like userid and password to validate the transfer.
public setField ( string key, string str ) : void
key string The form field name
str string The form field value
return void

setFilename() public method

Used to signal we want the output to go to a text file verses being transfered to a URL.
public setFilename ( string path ) : void
path string
return void

writeString() public method

Mainly used to turn the string into a byte buffer and then write it to our IO stream.
public writeString ( System io, string str ) : void
io System The io stream for output.
str string The data to write.
return void

Property Details

coRequest protected_oe property

Used mainly to avoid passing parameters to other routines. Could have been local to sendFile().
protected HttpWebRequest,System.Net coRequest
return System.Net.HttpWebRequest