Images/Pictures/BLOBs

I see what you mean. we will see if we can support Qodly Sources as well.

Thanks so much. This would really help!

Read that. So to clarify…

Drag file onto component

Click upload

http handler is called based on url provided in component setup.

Using the http handler template class/function, it appears to return a response variable somewhere that is of type object and has attribute body. ie response.body == “Upload went great.” or it could be response.body == “There was a problem etc.”

So would I create a datastore function to be run on upload success or upload failure events of the component, say

exposed function getUploadResult():object
var event:object
var data:object
event = webEvent
data = event.data
return data

Is this the correct structure for the function?

Does the function need to include any parameter if it is called during the on upload success or on upload failure events of the component?

Does the returned data variable == the response object variable returned from the http handler?

yes you can use it like this.

yes it will be the result of the api you did use. in your case it will be the http Handler in other cases it can be for example a aws lambda function to store the file in S3 and you need the object name to save it in database.

you can add a trace before return and check the object to see if it’s good or not

Not working yet, but will keep trying. I noticed that in the httpHandler documentation that for file uploads the required verb is POST. If so, does that mean I cannot pass in params as part of url querystring likie I would do with GET?

can you show us your http Handler configuration ?

The Handler Config:

The Handler Class/Function:

The Page/Component:

If I can get the uploaded file into the Shared folder that is good start.

If the document is not stored directly in the DB CUSTOMER_DOCUMENT Table as Blob or image, i want the url link to the document to be:

url/[CUSTOMER_DOCUMENT.ID].(pdf jpg etc.) so i can store the url as a string field in the CUSTOMER_DOCUMENT record.

1 Like

That’s a good start. Next, you’ll need to implement another function or HTTP handler to retrieve the file from the Shared Folder, as direct access via a shared link is restricted for security reasons. Meanwhile, I’ll start working on adding Qodly Sources to DropZone to support variable URLs.

Thanks @ayoub and @mikey . From my tinkering and asking AI it looks like–:

if the API you are using, ie MS Graph (the one I am trying to get working now) wants you to POST the request to their API, the body will generally simply contain the key value pairs you want/need to POST, and you put them there in a reasonably standard format “foo=bar&rain=shine…etc” as @mikey indicated.

However, the trick comes in when you want to POST some key value data pairs AND a file/binary type data like a pdf. in the POST to the API.

In this situation there is a standard approach it looks like where the key value pairs are included in a defined “boundary” of the body, then you need to add another “Boundary” to the body to hold the binary file.

This is a muiltipart encoded POST. AI indicated that 4D does not yet have a built in way to handle this, and it produced a sizeable chunk of 4D code that manually creates the body and boundaries in 4D to use for posting… its a good chunk of code…

It would be good if 4DHTTPRequest just had a built in way to more seamlessly handle multipart POSTS using the 4DHTTPRequest, and for file upload components to pass key value pairs in addition to the file when POSTED to 4D HTTPHandler. :slight_smile: . If we want to upload pdf, excel, ms word, and images and store directly in 4D/Qodly DB, file upload components should support save direct to db field as well, and we should be able to get files in and out of DB Blob/image fields for display or download, would be cool.

Thanks for help and almost at the end of this open new account piece…

we did add support for qodly Source in DropZone component.

You can use your qodly source to build the url for example
/api/123?var=456

in this example you will only need one httpHandler /api to get the additional params

Thx @ayoub Good news!

DROPZONE: Cool. So even though its a POST, we can still add params onto the url like a GET, then the binary/file data will be sent in the body? Handler URL can now be a qodlysource. Cool.

If the Dropzone component handles multiple files at one time, how would request.body be parsed to get the multiple files?

=============

Also Some basic related foggyness:

Am I correct in assuming that the HTTP Request Handler is designed with the intent to send and accept REST data to from others, but not to render qodlypages?

In php, if user requests mysite.com/getproductinfo?productid=5 the server will take the request, populate the specific getproductinfo page with the data, then respond with the updated/populated getproducts page to the user’s web browser.

I am thinking the qodly HTTPHandlers do not send back the populated “getproductinfo” qodlypage on such a request, but rather return REST data to the requestor via body/headers etc. for further processing by the requestor?

I am about to activate public access and want guests to be able to get to the login page, the register new account page, and an upload_docs_page without logging in. Will the page names be public and static in qodly, ie:

if my qodlypage is named “login”, will https://www.myqodlysite/login will return the login page(if privileges permit), and if i also have a register page, will https://www.myqodlysite.com/register serve the register page?

And finally, per my question above, if I have a page called “uploadthisnewcustomersdocshere”, and a public user requests: https://myqodlysite.com/uploadthisnewcustomersdocshere?encryptedcustomerid=45AC6678xxyyxx

Will qodly process the querystring and use it to setup my qodlysources on that page for that customer per my handler and other fucntions etc, and then render the uploadthisnewcustomersdocshere qodlypage ?

Before I activate public access want to make sure I get a basic handle on the approach. thx!