File Uploads - Solved -- Works great..so far!

Sharing if it helps anyone:

Summary: Using the standard File Uploader and a Blob entity attribute (Not Picture) your user can upload most types of files or images and:

-You can get the file easily into the Bound Blob entity attribute and it will even display it in an image viewer if it happens to be an image type of file.

-You can next add a little function to easily get the File from the Blob attribute in the DB to a 4D.File and onto the file system:

exposed function saveFileToShared(customer:cs.CUSTOMEREntity):string
	var theFile:4D.File = file("/SOURCES/Shared/customer_documents/robstest2")
	theFile.setContent(customer.identity_document2)
	customer.save()
    return "OK"

-Once the File on the filesystem as a 4D.File , it becomes straightforward to send where needed, if needed, via 4D.HttpRequest etc.

NOTES:

-Even though I saved the file to the Qodly filesystem without .pdf or .jpg on the end, when I downloaded it to my local machine and opened, the system knew which type of file it was and opened using correct app.–Hooray!

Qodly has 2 types of file attributes: a Picture, and a Blob–don’t use Picture

(The Blob attribute in a DB Table can store both Pictures and other types of files like pdf.)

The standard File Uploader in Qodly can be attached to a dataclass entity attribute of type Blob. ie: customer.identity_document (a Blob attribute of the Customer Class)

Do not try to bind the uploader to a qodly page source of type blob. I think the Blob type in the dataclasses is a 4D.Blob vs a blob and there are some differences. Stick to binding it to a dataclass entity Blob attribute.

1 Like