PutData Method  

Upload the data in a string or byte array buffer to the storage container.


object.PutData( ObjectLabel, Buffer, [Length], [ContentType], [Attributes] )


A string which specifies the label of the object that should be uploaded to the server. If an object with the same label already exists, it will be replaced with the contents of the buffer.
This parameter specifies the buffer that contains the object data to be stored. If the variable is a String type, then the data will be stored as text. If the buffer contains binary data, the buffer must be specified as a Byte array.
An optional integer argument that specifies the number of bytes to be stored. If this parameter is omitted, the length is determined by the length of the string or size of the byte array buffer provided by the caller.
An optional string argument that identifies the contents of the buffer being stored. If this parameter is omitted, or specifies a zero-length string, the method will attempt to automatically determine the content type based on the object label and the contents of the buffer.
An optional integer argument which specifies the attributes associated with the storage object. This value can be a combination of one or more of the following bitflags using a bitwise OR operation. If this parameter is omitted, the default attribute webObjectNormal will be used.
Value Constant Description
1 webObjectNormal A normal object that that can be read and modified by the application. This is the default attribute for new objects that are created by the application.
2 webObjectReadOnly A read-only object that can only be read by the application. Attempts to modify or replace the contents of the object will fail. Read-only objects can be deleted.
4 webObjectHidden A hidden object. Objects with this attribute are not returned when enumerated using the FindFirst and FindNext methods. The object can only be accessed directly when specifying its label.

Return Value

A value of True is returned on success. If an error occurs, a value of False is returned and the LastError property will return the specific cause of the failure..


The PutData method uploads the contents of a buffer to the current storage container. If an object exists with the same label, it will be replaced. During the transfer, the OnProgress event will fire periodically, enabling the application to update any user interface objects such as a progress bar.

Although storage object labels are similar to Windows file names, they are case-sensitive. When requesting information about an object, your application must specify the label name exactly as it was created using this method. The object label cannot contain wildcard characters.

If the label identifies an object that already exists in the container, and that object was created with the webObjectReadOnly attribute, this method will fail. To replace a read-only object, the application must explicitly move, rename or delete the existing object.

If a content type is provided, it must specify a valid MIME media type and subtype. For example, normal text has a content type of text/plain while XML-formatted text would have a content type of text/xml. Data that contains unstructured binary data is typically identified as application/octet-stream. If you do not specify a content type, an appropriate content type will be determined automatically based on the label and the contents of the buffer.

If you wish to upload the contents of a file, use the PutFile method.

When this method returns, various properties such as ObjectId and ObjectLabel will be updated to reflect the values associated with the object that was created or replaced on the server.

See Also

GetData Method, GetFile Method, PutFile Method, OnProgress Event