How to upload files from a HTML form to a Webhandler?

Posted by Eduardo Aceves Ledezma on 12-Sep-2016 09:40

I'm a new member to the developers community so, Hi Everyone!

Right now, we're building a RESTful application for a DMS (Document Management System). 

Since it's a very large scale app, we're trying to use Webhandlers as the resource for uploading files to the server. The problem is that none of us know how to correctly process the request and get the binary file data to save it.

Is there a tutorial, or some information on how to do this?

Regards!

Posted by Irfan on 12-Sep-2016 13:42

Please find attached the code to be used for uploading binary file. This example will write the binary to a file and return it back to the client. You can choose to insert the image to database instead of writing to a file[View:/cfs-file/__key/communityserver-discussions-components-files/19/TestBinary.cls:320:240]

All Replies

Posted by Irfan on 12-Sep-2016 09:52

[View:/cfs-file/__key/communityserver-discussions-components-files/19/7416.UploadFiles.cls:320:240]

Posted by Irfan on 12-Sep-2016 09:59

Please find attached the WebHandlers source code to accept binary payload in the earlier post. Also, below is the client code I used to test it(I am having problem uploading files)

<!DOCTYPE html>
<html>
<head>
    <base href="demos.telerik.com/.../index">
    <style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
    <title></title>
    <link rel="stylesheet" href="cdn.kendostatic.com/.../kendo.common-material.min.css" />
    <link rel="stylesheet" href="cdn.kendostatic.com/.../kendo.material.min.css" />

    <script src="cdn.kendostatic.com/.../script>
    <script src="cdn.kendostatic.com/.../script>
</head>
<body>

          <style>
  .hide { position:absolute; top:-1px; left:-1px; width:1px; height:1px; }
</style>

<iframe name="hiddenFrame" class="hide"></iframe>
            <form method="post" action="localhost:2264/.../upload" enctype="multipart/form-data" target="hiddenFrame">
                <div class="demo-section k-content">
                    <input name="files" id="files" type="file" />
                    <p style="padding-top: 1em; text-align: right">
                        <input type="submit" value="Submit" class="k-button k-primary" />
                    </p>
                </div>
            </form>
            <script>
                $(document).ready(function() {
                    $("#files").kendoUpload();
                });
            </script>
        </div>


</body>
</html>

Posted by Eduardo Aceves Ledezma on 12-Sep-2016 11:11

Hi [mention:54e5df2f11a046ef89f0b4acd415e0d5:e9ed411860ed4f2ba0265705b8793d05] !

Thanks for your answer. The code seems okay for me, but I keep getting this error on the OEPAS agent log:

ERROR: Binary file upload is not supported. (8868)

I've checked this article: knowledgebase.progress.com/.../000043799 , but it didn't help since I'm using PAS and not the Webspeed broker.

Do you know how to solve this?

Regards!

Posted by Irfan on 12-Sep-2016 11:13

Which version are you running ? I think with 11.6.1 version you might get this error but it does not harm

Posted by Eduardo Aceves Ledezma on 12-Sep-2016 11:54

Hi [mention:54e5df2f11a046ef89f0b4acd415e0d5:e9ed411860ed4f2ba0265705b8793d05]

I'm running 11.6, I don't have any SP installed.

After the log message that I've told you before, I'm getting this one: Could not locate method 'GetBytes' with matching signature in class 'OpenEdge.Core.Memptr'. (14457).

Do you know the reason of this last error?

Thanks a lot for your help.

Posted by Irfan on 12-Sep-2016 12:27

Okay, the code I have given you is to upload multipart binary data and I think it is not available in 11.6 FCS. Let me send you the code that would just take the binary payload

Posted by Irfan on 12-Sep-2016 13:42

Please find attached the code to be used for uploading binary file. This example will write the binary to a file and return it back to the client. You can choose to insert the image to database instead of writing to a file[View:/cfs-file/__key/communityserver-discussions-components-files/19/TestBinary.cls:320:240]

This thread is closed