SendCustomRequest Method
Allows the sending of a custom request to an Amazon web service.
Syntax
amazons3.sendCustomRequest(url, requestData, otherHeaders, [callback])
Callback
The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).
The callback for this method is defined as:
function(err, data){ }
'err' is the error that occurred. If there was no error, then 'err' is 'null'.
'data' is the value returned by the method.
'err' has 2 properties which hold detailed information:
err.code err.message
Remarks
SendCustomRequest allows a user to send a custom request to any Amazon web service.
If the RequestData parameter is empty, the class will perform an HTTP GET to the URL you specify. The class will automatically generate a proper signature and timestamp, but the user is responsible for providing all of the required and optional parameters through the Url parameter, as required by the Amazon web service documentation. The OtherHeaders parameter is used to submit any additional headers required by the service you are using.
For the S3 class, you may submit RequestData in an HTTP PUT to the Url you specify. The Url is normally fully-qualified, but for PUTs only, may be a relative path. If a relative path is supplied, the Amazon web service URL is used as the remote host, the Bucket property is used to create the path, and the Url parameter is used as the object.
PUTs are not currently supported by any other classs, but you may submit a custom request containing RequestData with any class if you set the SignCustomRequest configuration setting to False.
When SignCustomRequest is False the user is responsible for generating a proper signature, timestamp, and providing all of the required and optional parameters through the Url parameter, as required by the Amazon web service documentation. The class will pass the request as-is without modification.
In addition to the default supported operations, HTTPMethod can be set to specify the HTTP Method that you wish to perform.
This method will return the entire HTTP response as a result of the Amazon web service call. The GetXValue method can be used to fetch response information using XPath after a successful call to SendCustomRequest.
For example, to submit a Versioning Configuration request to Amazon, you would use the following code:
string request = "<VersioningConfiguration xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">\r\n<Status>Enabled</Status>\r\n</VersioningConfiguration>"; s3.SendCustomRequest("http://s3.amazonaws.com/versioningtestlive/?versioning", request, "");To submit the same request when using Virtual Hosting, you would use the this code instead:
s3.SendCustomRequest("http://versioningtestlive.s3.amazonaws.com/?versioning", request, "");Finally, you may specify the Bucket and put the object name in the Url parameter like this:
s3.Bucket = "versioningtestlive"; s3.SendCustomRequest("versioning", request, "");In the last case, the URL the class submits to is dependent on the value of the UseVirtualHosting property.