PutData Method  
 

Transfer data from a local buffer to the server.

Syntax

object.PutData( Resource, Buffer, [Length], [Reserved] )

Parameters

Resource
A string that specifies the resource on the server that will receive the data being transferred. If the resource is a file on the server, the contents will be replaced with the data provided in the buffer.
Buffer
This parameter specifies the local buffer that the data will be copied from. If the variable is a String type, then the data will be written as a string of characters. This is the most appropriate data type to use if the file on the server is a text file. If the remote file should contain binary data, it is recommended that a Byte array variable be specified as the argument to this method.
Length
An optional integer argument that specifies the amount of data to be copied from the buffer. If this argument is omitted, the entire contents of the buffer is transferred to the server.
Reserved
An argument reserved for future expansion. This argument should always be omitted or specified as a numeric value of zero.

Return Value

A value of zero is returned if the operation was successful, otherwise a non-zero error code is returned which indicates the cause of the failure.

Remarks

The PutData method transfers data from a local buffer and submits to the server using the PUT command. If a String variable is used for the buffer, the text will be automatically UTF-8 encoded before it is submitted to the server. If you need to submit binary data, you should always use a Byte array as the buffer rather than a String. If you need to use something other than UTF-8 encoding, use the PutText method in combination with the CodePage parameter to specify an alternate encoding.

Not all servers will accept data submitted using this method, and some may require that specific configuration changes be made to the server in order to support the PUT command. Consult your server's technical reference documentation to see if it supports the PUT command, and if so, what must be done to enable it. It may be required that the client authenticate itself by setting the UserName and Password properties prior to uploading the data.

If the Buffer parameter is a String type, this method presumes that it only contains text and will automatically convert the contents to UTF-8 encoded text. If the string contains binary data, this encoding can corrupt the data. To prevent this conversion, convert the string to a byte array using the StrConv function.

This method will cause the current thread to block until the file transfer completes, a timeout occurs or the transfer is canceled. During the transfer, the OnProgress event will fire periodically, enabling the application to update any user interface objects such as a progress bar.

See Also

GetData Method, GetFile Method, PostData Method, PutFile Method, OnProgress Event