Automation Professionals' Blob Server Module

I recommend you test in three steps:

  • In the Named Query editor, use test mode with that ID to make sure you get one row, and only one row. Make sure the column names' are the correct mix of upper and lower case. Make sure the project is saved after testing the NQ.

  • In a browser tab adjacent to the Perspective session, put the test URL directly into the browser (not an i-frame). You should see the content directly in that tab.

  • Only then, test in the Perspective session itself.

For all of these tests, monitor the gateway log looking for related errors.

1 Like

Thanks, Phil.
My ID parameter in the URL used the wrong case.
Parameter defined in NQ: "ID"
Parameter in URL was "id"

1 Like

Hi Phil,
I'm using the module to display a pdf file, it works fine when I test the URL directly into the browser, but If I paste the same URL into the PDF Viewer source, it shows "Fail to load PDF file", any suggestion?
Thanks!

I've found I need to remove the Gateway IP and port from the URL, in order for the PDF Viewer to display the document (?)

1 Like

Hmm. No idea. If it shows in the browser, then the module is working properly. Not sure what quirks are in the PDF Viewer.

Phil, is there any way to add/modify the Content-Disposition header? A browser on my PC opens the PDF file in another tab as expected, but on my mobile device it wants to download the PDF first then open in PDF viewer. I have read that specifying Content-Disposition: inline; as opposed to Content-Disposition: attachment; would solve this. And, it has the added benefit of specifying the filename too. Currently the suggested filename is "GetPDFReport" as that is the name of my named query.

Content-Type: application/pdf
Content-Disposition: inline; filename="parameterizedfilename.pdf"

Thanks!

Sure. Easy-peasy, I think. Try this:

v1.1.0.231421939

Return an optional third column, ContentDisposition, from your named query with your desired header content. Be sure to embed the quotes into the value if you supply the filename.

1 Like

This is working great for vision also. Thank you a great tool saves a lot of coding.

1 Like

@pturmel @JohnMck

I am using SQL Server as John is, and am wondering how to set this up.
I'm reading through the MSDN docs on FILESTREAM, FileTable, etc. and am not sure if I need to go through all this, as in your module docs, Phil, you didn't mention anything about that.

What I would like to do is allow select users to upload images, PDFs, Word docs to this DB, associate the files with some machine, then view the files.

So, do I need a FILESTREAM enabled Server and the requisites following that on the MSDN? Which also means, at least recommended, having a separate disk volume for the separate server. (I think it said separate server... Maybe just a FILESTREAM enabled server)

Or, is it ok to use a normal server/DB for this job and will it affect performance much considering a small group of users (200 or less)?

Thanks!

I avoid Microsoft products like the plague (well, more than like a plague) so have not had occasion to set up blob columns. I doubt you need filestream or filetable special handling, but I'm not the one to ask.

I would not expect you to need anything special in your DB, unless you expect to handle hundreds of gigabytes total. If you plan on storing video, consider using a segmenter to store a few seconds per chunk. You definitely do not want to have any blobs that make up more than a percent or two of your gateway's RAM allocation.

1 Like

If I understand your blob server correctly, the images (or other files) are actually stored in the DB.

I can setup a DB (MSSQL :slight_smile: ) with file names, etc., but displaying them I'm not sure about. If I recall correctly, @cmallonee mentioned that images (and perhaps other files) stored outside of the Image Management tool are not supported.

Bottom line is: (should I create a new thread for this question?)
I want to access and display files/images from a network shared folder in Perspective using MSSQL Server.

Do you (or anyone really) know of a way to access files stored on a network shared folder (which is where we'd like to keep our files) from Ignition?

Just use WebDev to access the shared folder (use UNC names for robustness).

My Blob Server will only do blobs stored directly in the DB.

I need to select my image based on a column called "initials" that contains a string datatype. Anyway to adjust the namedQuery to use a string instead or int? Or can I adjust the query to select the id that corresponds to the initials? Sorry, I'm not a MySQL expert.

All you need to do is modify the query to fit your data, something like this:

WHERE initials = :initials

:initials being the parameter you pass to the query. You also want to be sure there aren't duplicate initials.

The URL parameters are strings, and are coerced to the NQ parameter value types by the NQ engine. String parameters should work fine.

Thanks! that worked for me too

Hi Phil,

I have implemented the blob server module into my form application. It has been working well. I have run into one problem where I am having trouble pulling files that contain a '#' in the file name. I get an HTTP ERROR 404 Not Found. I was wondering what could be causing this and if there is a possible work around.

Thanks

That is a special character in URLs. You will have to use URL escaping.

I have the file name saved in a separate column that the query utilizes. I have tried removing the # from the file name so that the URL would no longer include the #, but the error is still present.

Replace the # in the URL with %23, the encoded form of the hash mark. Use urlencoding in your scripts to auto-general these URL parameters. (It isn't just the hash mark that needs such treatment.)

https://docs.oracle.com/javase/8/docs/api/java/net/URLEncoder.html