HttpPutData Function  
 
INT WINAPI HttpPutData(
  HCLIENT hClient,  
  LPCTSTR lpszRemoteFile,  
  LPCVOID lpvBuffer,  
  DWORD dwLength,  
  DWORD dwReserved  
);

The HttpPutData function copies the contents of the specified buffer and stores it in a file on the server.

Parameters

hClient
Handle to the client session.
lpszRemoteFile
A null-terminated string that specifies the file on the server that will be created. This string may specify a valid URL for the current server that the client is connected to.
lpvBuffer
A buffer which will contain the data to be transferred from the client and stored in a file on the server.
dwLength
The number of bytes to copy from the buffer.
dwReserved
A reserved parameter. This value should always be zero.

Return Value

If the function succeeds, the return value is the server result code. If the function fails, the return value is HTTP_ERROR. To get extended error information, call HttpGetLastError.

Remarks

The HttpPutData function is used to store the contents of the specified buffer in a file on the server. Not all servers permit files to be created using this method, and some may require that specific configuration changes be made to the server in order to support this functionality. 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 using the HttpAuthenticate function prior to uploading the data.

This function is designed for uploading the contents of a buffer to be stored as a file on the server. If you need to use the PUT command to as part of a RESTful API where the PUT command is used to submit data to the server, use the HttpPutDataEx function. That function will return the success or failure responses back to the client.

This function will cause the current thread to block until the file transfer completes, a timeout occurs or the transfer is canceled. During the transfer, the HTTP_EVENT_PROGRESS event will be periodically fired, enabling the application to update any user interface controls. Event notification must be enabled, either by calling HttpEnableEvents, or by registering a callback function using the HttpRegisterEvent function.

To determine the current status of a transfer while it is in progress, use the HttpGetTransferStatus function.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtpv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also