Let’s work with files in ORACLE APEX.

Working with files now there are two different types of files that we’re talking about here and so we kind of classified them as development files and use your controlled files so what does that mean development files those are things that kind of you use as the developer to help either make your application look better or to add features via JavaScript or maybe you have helpful images that you want to put on your application, so these types of files don’t contain sensitive information they just contain functionality or they contain it’s basically a resource for your application now on the other hand and you might have user control files like say maybe you have a bunch of products and maybe a product has an image right so you want the user to kind of potentially be able to change the image associated with the product right, so that’s not really something that you manage that’s something that your users or your business manage to know how you go about controlling those user files really.

There are several ways to solve that but we are actually going to use the database to solve that because um it’s incredibly declarative and easy to hook into and you can actually set up and kind of file manager in just a couple of minutes ok so we’ve already talked about this from an optimization standpoint so I’m just going to kind of hit on a couple of the important things because in best practices we talked about how to store files and just a reminder file system generally is going to lead to better performance for two main reasons one is that you can put the file on like a web server or even like a content delivery network that is optimized for getting those files out and the other thing is and if you’re getting a file from a web server or somewhere other than your apex database and that’s one less hit to the database that’s one less request that your database has to process and that’s good you want to limit that if you want to scale your applications.

You want to limit the number of database requests that you’re throwing at your database now granted this is going to work fine I mean this isn’t going to [ __ ] your application in any way for like a standard user but if you start having you know hundreds made thousands of concurrent users and an application well these are things you’re going to really want to think about um as far as storing files in the database and it’s extremely convenient it’s much more convenient and that because you can access the files via the shear components modify them and something new with Apex 5 is you can simulate directories so in other words in apex 4 to basically all the files that you put in shared components were in one big global directory now I don’t know if you if you’ve seen this before but if you look at a lot of web applications they will have like an images directory and all the images go there.

I’ll have a scripts’ directory, not like the JavaScript will go there and have other reefs like a resource directory maybe PDFs or helpful things will go in there and that organization is a very important right and I mean when you write code you just kind of have one big file that you open up and you just dump everything into and not really right you’re going to organize that into two different procedures different functions different packages maybe organize things by schema right organization is probably the most important part to developing a successful application and being a successful developer so 8×5 realized that and so now we have a way to kind of simulate directories and I’ll show you what I mean by that in just a little oops let’s go ahead and actually let me show you first before I send you off on that head-on into my application builder I’m going to switch this back to report view because actually I really like the report view.

I’m going to go to my intermediate scratchpad and here what we’re going to do is we’re going to go ahead and add a logo for my application pretty straightforward so we’re going to do so by going to the shared components and in the shared components and we can add static files now there are two different types of files that you can add there are application files and workspace files I encourage you to disregard application files pretend that that doesn’t even exist why would I say that why would I encourage that well let’s pretend um you’re building like a regular application you are you’re working an irregular web environment well when you upload an image file or a resource on to your web server it’s pretty much going to be available for any application or page that wants to reference it so a basically if you were to limit a file to a single application I believe it actually makes things more confusing because you’ll want to use that file so you upload this file and then maybe you go oh.

Now I want to use it for my new application and you try to reference it and it just doesn’t work well doesn’t work because you kind of isolated that file to only be referenced by a single application now and it is there some advantages to having application-specific files sure I guess you could add some security if it’s an if it’s kind of a sensitive application or a sensitive file you could do that but for the most part I’d say the lion’s share of all app all files that you upload I would encourage you to upload them as static workspace files okay notice that you can download as zipping so as you add files and you add files with fake directories kind of in front of the apex will actually organize all of these files into a zip so you know maybe you’ve uploaded lots of files and then maybe the time comes where you say oh you know what I want to put this stuff up on my webserver instead of having to manually download one file at a time.

You can just say oh I want to download all these files as a zip and then I’m going to unzip those yet up onto my web server and very easy to them now be working off your file system on your web server rather than out of the database this is something new to 8x five, so this did not exist as a 42 if we want to upload a file you say upload and this is what I mean by a pseudo directory and it’s not really a directory it’s just a string literal that we can kind of use as a directory so in other words if I want to add something into that images directory that I used before I would just say images I can choose a file and I actually have you go back here working files I have a little skill builders logo that I’m going to use and I can upload and so now you can see I have images/skill builders logo site PNG I want to download an individual file well I can just click on the little download link and if I want to reference the file quite simply.

It’s been very helpful now this is new with Apex five they actually put the reference right next to the file which I don’t know why it took them so long to do that one thing that I will say and I try to keep everything lowercase I don’t try to mix case don’t use camel case for images and files and things and I keep everything in lowercase it just makes your life so much easier because you know the second you see a character that’s an uppercase something’s wrong so now I have this image uploaded how do I use it well I’m going to go ahead and use this as a logo for my site or for my application we’re gonna head on over to shared components and there’s a user interface attributes that I can modify let’s go ahead and let’s go there notice this page looks familiar and you can get you can also get to this by clicking on your application properties button and then clicking on this user interface tab.

And the last thing that we’re going to do here is we’re just going to change the logotype make sure you change it from text to image go ahead and paste that reference there ok so I can actually say the alt here is skill builders and the title we’re going to call that skill builder and let me actually just do their little here we go awesome I’m actually not going to add this style I’m going to get rid of that and I’m actually going to show you why the alt and the title are both important go ahead and apply changes run my application it’s going to make me login of course and I have the little skill builders logo up on the top but what if something happens to my skill builders logo so I have the title where if I mouse over it says skill builders hey that’s useful but what happens if that file disappears or something’s just not right so what I’m going to do is, I’m going to add a typo here.

I’m just going to delete the e, so that’s an invalid reference to a file which most browsers will do for you is if you have the alt of skill builders it’s actually just going to say skill builders so it kind of it tries to do its best to kind of preserve some text so you can put some text there it shows you you can see that it’s a broken link right it says it’s a broken image link you can see that but also it has the Texas skill builders, ok let’s go ahead and do the first workshop it’s pretty quick one to just go ahead and change the logo of your application this one should really only take about five minutes to do so what I would like for you to do is go back close this okay I want you to up a module 12 I want you to upload skill builders logo site and I would like for you to make that the logo of your application I’m going to go ahead and give you five minutes and check in it shouldn’t take much longer than that thanks all send done your application should look something like this yeah.

So you got because what I would do let’s say I had a custom here’s a great example um let’s say I remember we made that custom template change for the red or blue highlighting for the high salary report well.

Leave a Comment