FileUpload

TwinCAT TIA
Network REST Client ActiveClients One client

ns=2;s=DEPRAG Smart/Network/HTTP/REST/ActiveClients/0/FileUpload

Uploads a file to the specified endpoint.

Parameters:

Returns:

    FileUpload
    A variable of type OpcMethodReturnValueHttpResultWithStringContent. The Result property contains the command-specific return values.
      Result
      A variable of type HttpResultWithStringContent.
        Success
        Indicates whether the HTTP command was successfully fired.

Examples:

In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:

Beckhoff parameter:

    bHttpFileUpload
    A boolean variable that can be used to trigger the execution of the FileUpload command.
    OutputDataHttpFileUpload
    An instance of the ST_HttpResultWithStringContentOutputData structure to which the return value of the FileUpload method is written.
    hrHttpFileUpload
    This can be used to monitor the execution of the command. Error codes have the type HRESULT.
    fbHttpRest
    An instance of the "FB_HttpRest" function block supplied with the DEPRAG Smart library.
    sRequestUri
    A string(255) variable specifying the endpoint to which the command should be sent.
    Content
    A variable of type "ARRAY[*] OF BYTE" containing the data to be sent.
    nContentLength
    A UINT variable that specifies the length of the data to be sent.
    sClientId
    A String(255) variable that specifies the client that should execute the command.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
   bHttpFileUpload    : BOOL;
   OutputDataHttpFileUpload : ST_HttpResultWithStringContentOutputData;
   hrHttpFileUpload   : HRESULT;
   testLongByteArray : ARRAY[1..1000] OF BYTE := [84, 101, 115, 116, 255, 84, 101, 115, 255];
   fbHttpRest   : FB_HttpRest;
END_VAR

hrHttpFileUpload := fbHttpRest.FileUpload(
         bExecute   := bHttpFileUpload, 
         ConnectionHandle:= depragSmartConnection.ConnectionHandle,
         sRequestUri  := '/testFileUpload',
         Content   := testLongByteArray,
         nContentLength := 9,
         sClientId   := '0',
         OutputData  => OutputDataHttpFileUpload);
IF hrHttpFileUpload <> S_FALSE THEN 
    bHttpFileUpload := FALSE;
END_IF
                                                    

For examples and explanations regarding the calls of nodes via Siemens TIA Portal please refer to the sub-menu "Siemens TIA Portal" in section "Getting Started".