Images/Pictures/BLOBs

We require people to upload copies of their ID (and other documents) as part of our onboarding process.

Some questions about file/image upload, storage, and retrieval for documents/images stored in an attribute field in a table. (Currently the proposed way I’m doing it, bit open to url concept if better.)

We will get some jpgs etc. from customers, but alot of pdf too for upload.

Currently I’m using the file uploader component, and a button underneath it to save uploaded document (and some other document data (document type, etc.)) as a record in the CUSTOMER_DOCUMENT Table.

An image component for the uploaded document is also on the page as well for now just to see how it works. JPEG seems to work fine, and when uploaded, the JPEG image is displayed in the image component so seems to upload fine when JPEG file type uploaded.

  1. PDF: Do not see it in the image component after upload and can’t tell if it uploaded ok? Issues with pdf? Pretty popular document upload type…
  2. How to view or download the document stored in the attribute field?
  3. Any pros cons of storing the Identity Document in an attribute field in the CUSTOMER_DOCUMENT Table vs storing in filesystem?

Thanks for ideas. Almost done with customer account setup, …..then on to login process…

Hello Robert,

In your case, custom components can be used to handle both display and download of uploaded files stored in your blob/picture attribute fields.

For display:

  • You can use the provided Image component for image files.
  • You can use the PDF Viewer custom component for PDF files.

To allow users to download the uploaded file, you can use the File Download component.
This setup will ensure proper handling of different file types.

The pdf viewer does not seem to display pdfs uploaded to a picture attribute using the file uploader tool. JPEGs display fine in the image component.

How can pdf files be uploaded? It seems they are not being stored in the picture field.

Which media type would be selected in the file upload component for pdf?

Hey @musseman,

PDFs are blobs. you shouldn’t save them in a image field.
there’s blob type that you can use to save a file in the Database

1 Like

So i dont know if user will upload a pdf or a jpg for their drivers license.

Testing:

In the CUSTOMER_DOCUMENT Table, i changed the file attribute from picture type to BLOB type.

I went to the qodly page.

The file upload component asks for a media type in its config area. Not sure what to put, so stuck with image/*

When I click the upload button the file explorer pops up as expected, but pdfs are greyed out by default. Had to click a little “show options” button and select “all files” to make pdf’s available to upload.

Tried to upload a pdf to the file attribute in the Table and looks like no luck?

in your case i would recommend using HTTP Handlers with this custom component DropZone.
it will help you send files to the server side and then process them.

I looked at DropZone:

  1. I don’t see the zip file that is demonstrated n the documentation for custom component upload? Which file should I upload?
  2. Is there an example of uploading a file to:
    1. A folder in the qodly application shared folder
    2. A Blob or image field in a qodly Table
    3. some outside server

that could be included in the component’s instructions/Readme?

Thx.

1 Like

I saw where the zip file can be found for custom components in github. It is the RELEASE area on the right hand side about half way down. Will try dropzone now. Thx.

1 Like

you can check the example we have to upload file in

we will update the readMe of the custom component to add more examples.

I read the example. Thx. 2 questions:

  1. Where would this file in the example be stored?:

file = file(“/PACKAGE/Files/”+fileName+“.pdf”)

I don’t see a PACKAGE folder in the app folders?

I could maybe create a PACKAGES or other folder in Shared to store the files?

  1. For filetypes/name extensions: Would it be good to add code in the example provided with the following logic: If the filename already ends in .pdf .jpg .jpeg .png etc…dont add a filetype at the end, but if it does not end with a .pdf, for example, and the mime type was application/pdf, then append .pdf on the end. I imagine most files will have the extension already when they come over and this avoids saving as .pdf.pdf ?

if you want to save it in a folder “files” in your shared folder then you can use folderVar = Folder(“/SOURCES/Shared/files“) to get access to folder folderVar.file("yourfileName")

Thx. Can try that for sure.

Last item before I try it tomorrow.

In the shared singleton class/function in the example, would appending code like the following at near end of the function after file is created have any issues:

var customerdocument:cs.CUSTOMER_DOCUMENT = ds.CUSTOMER_DOCUMENT.new()
customerdocument.type = “Identity Document”
customerdocument.expiration_date = date(1,1,2029)
customerdocument.url = [the URL to the file we just created on the server.]
customerdocument.save()

Then would it work that when a user clicks a button to navigate to or open the url saved in the record, the browser would open or download the stored document?

This from documentation seems to indicate i can use buttons etc to open URL’s to files

  • Shared: Use this folder to store any contents (local images, downloadable files…) you might need within your app. The contents of this folder can be accessed from Qodyy pages using the /$shared link or from the QodlyScript language using the /SOURCES/Shared file path.

Wonder if I have control over whether the broweser opens or downloads the pdfs when the button to navigate to the file is clicked?

yes it’s possible.
here’s this blog that you can read to have some fresh ideas of how to manage download files or images

I setup the singleton class using the example in the documentation. Some notes:

  1. looks like the example should change:

var file : 4D.File to something like var thefile:4D.File editor did not like usinf the word file for var. Maybe its a keyword..?

  1. I also get this warning on lines in the example like

request.getHeader("Content-Type")

It says that: “The function or property getHeader does not exist on type 4D.IncomingMessage (550.2)”

Once I have feedback on these things I will start trying tomorrow.

Thanks again for all the help!

you can also create a new route in your http handlers /download/id and when you set the id you can download the file
your http handler can use the id (user id for example) to look for the document or image and then send it back to server.

I have setup the http handler and shared singleton class per the instructions and will try to get it to work. One area that is still foggy:

User Drags file onto drop zone and clicks to upload. The http request handler processes the upload then returns a response.

–Where is the response– ie (error, or file uploaded good. etc.) captured/stored so i can access it? ie How do I access the response so I can use it to displat a message etc.?

The singleton class for the handler is: UploadCustomerFile. The function is: processFileUpload

Thx.

The URL property in the dropzone looks like it only supports static text.

When my page is loaded the page is for a speciic CUSTOMER and the customer.ID is available

The url for DropZone would be something like:

/uploadCustDoc?custid=[customerID]&expirationdate=[expdate]&doctype=IdentityDocument"

How can i get those variables into the URL. It seems to only allow for static text?

the dropZOne have many events that you can use

you can them to display a message or even send the result to another backend function.