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.
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…
How to view or download the document stored in the attribute field?
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…
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 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.
I could maybe create a PACKAGES or other folder in Shared to store the files?
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")
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?
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