PutBin

Syntax

<web service URL>/PutBin?<operation parameters>

Description

The PutBin operation is used to load binary data to server using POST request.

Comments

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:
  • <repository connection moniker>!Bin!$New. It is used to load a new binary object sent in response body to server. The object loaded from the server can be further loaded by means of the GetBin or GetBinary operation.
  • <express report moniker>!Load!Express. It is used to load settings and data saved in a PPEXPRESS file (*.ppexpress) to express report. File contents is sent in the request body.
  • <express report moniker>!Load!Cube. It is used to load data saved in a PPCUBE file (*.ppcube) to express report. File contents is sent in the request body.
  • <repository connection moniker>!$Sys! + <repository_document_identifier>. It is used to load a repository with the specified identifier of file contents sent in response body to document.
  • <dashboard moniker>!BinItem!New. It is used to load a new image to dashboard. Image is sent in the request body. Identifier and key will be generated for loaded image.
  • <dashboard moniker>!BinItem! + <id/key>. It is used to load an image to dashboard and assign the specified identifier or key to the image. It an element with the specified identifier or key already exists, it will be replaced. Image is sent in the request body.
  • <repository connection moniker>!<id/folder key>. It is used to create a new document in the specified folder. Contents of the file that will be saved in the document is sent in the request body. It is used with the createNewDoc parameter.
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:

These monikers can be used in the GetBin operation.

Example

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:

Additional Operations