<web service URL>/PutBin?<operation parameters>
The PutBin operation is used to load binary data to server using POST request.
Operation parameters contain a moniker and different additional parameters. Depending on the object, for which operation is executed, the repository connection moniker or the opened object instance moniker is specified as a moniker. The required monikers are returned by various Open* operations.
A parameter and its value are separated with the = character in the address bar; different parameters are separated with the & character.
Available parameters of the PutBin operation:
Parameters | Description |
mon | Moniker of the object, for which operation is executed. Available moniker types:
|
format | Loaded file format. |
fileName | Loaded file name. If the parameter it not specified, name is obtained from the file sent in request body. |
data | A binary file loaded to document. |
createNewDoc | Indicates whether to create a new document in a repository and load a file to it that is sent in request body. Available parameter value - 1. The mandatory condition is passing repository folder moniker in the mon parameter. |
IMPORTANT. Parameter names are case-sensitive.
The operation results in the loaded object moniker. Moniker format depends on the object moniker, for which the operation is executed:
<repository connection moniker>!Bin! + <key>. Moniker of new loaded binary object.
<express report moniker>!Load! + <key>. Moniker of loaded express report.
<repository connection moniker>!$Sys! + <key>. Moniker of the changed repository document, to which the new file is loaded.
<dashboard moniker>!BinItem! + <key>. Moniker of new or changed dashboard image.
<repository connection moniker>! + <key>. Moniker of created document.
These monikers can be used in the GetBin operation.
Below is the example of code of HTML page that is used to send data to server by means of the PutBin operation. A form implemented on the HTML page is sent as a value. The data is sent by clicking the hyperlink.
To reduce the example, the PostRequest function script is excluded from the code, the function is used to execute operations in JSON format. See code of this function in the Connecting to Repository article.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Use PutBin operation</title>
</head>
<body>
<script type="text/javascript">
var svc = "http://localhost:9090/axis2/services/PP.SOM.Som";
function getFormElement(id) {
res = document.getElementById(id);
return res;
}
function sendForm(form, url) {
sta = getFormElement('status');
sta.innerHTML = '';
xhr = new XMLHttpRequest(),
xhr.open('POST', url, false);
data = new FormData(form);
xhr.send(data);
if (xhr.status == 200) {
sta.innerHTML = "Response:<p>" + xhr.responseText + "<p>";
} else {
sta.innerHTML = "Request execution error:<p>" + xhr.responseText + "<p>";
}
}
// Connect to repository and send request for the PutBin operation execution
function PutBin(form) {
OpenMetabase = { "OpenMetabase": { "tDef": { "id": "PPREPOSITORY" }, "tCreds": { "user": { "id": "pprepository" }, "pass": "pprepository" } } }
//Repository connection
OpenMetabaseResult = PostRequest(svc, OpenMetabase);
//Send data to server
return sendForm(form, svc + "/PutBin?mon=" + OpenMetabaseResult.OpenMetabaseResult.id + "!Bin!$New");
}
/*
Script for PostRequest
*/
</script>
<!--A form, which data is sent to server-->
<form id="fileForm" action="" method="" enctype="multipart/form-data" onsubmit="PutBin(this)">
<div>
<input type="text" name="name" id="name" />
<input type="file" name="file" id="file" />
</div>
</form>
<!--Hyperlink for sending data-->
<div>
<a href="javascript:PutBin(getFormElement('fileForm'))">PutBin</a>
</div>
<!--A field for creating operation execution state-->
<div id="status"></div>
</body>
</html>
See also: