Uploaded pictures in HTML Attribute

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
srufini
Posts: 34
Joined: Thu May 23, 2019 11:23 pm

Uploaded pictures in HTML Attribute

Post by srufini »

While I am still hoping that one day I will be able to have an editor where I can simply past pictures (), I would like to just insert the html address of pictures that I upload in a BO in another text/HTML attribute of the same BO.
I have 2 isse to overcome:

1. All my pictures are stored in the filesystem. How can I retrieve the URL of a pictures in a filesystem? If I can copy the url of a picture from the browser, I get a temporary storage of awareim, not the actual location.
2. As optional, I would like to create an operation that copy the URL in the clipboard of the user, so it can be pasted in the HTML editor, inside the img tag.

I believe that anyone of you sing html fields have the same need I have and maybe implemented some elegant solution.

Please share your experience.

Thanks

Sergio
srufini
Posts: 34
Joined: Thu May 23, 2019 11:23 pm

Re: Uploaded pictures in HTML Attribute

Post by srufini »

I already saw the post here:

https://www.awareim.com/forum/viewtopic.php?t=10738

but the part that describes how to retrieve the URL of a picture stored on filesystem is omitted.

I know the filepath, but the URL is not so abvious to me.

Please advise.

Thanks

Sergio
Jaymer
Posts: 2454
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Tomcat root directory

Post by Jaymer »

1. are you aware of the concept that Images (or any item accessible on your website, via Tomcat) must exist "under" the Tomcat root directory?

C:\AwareIM\Tomcat\webapps\AwareIM

this is set here: C:\AwareIM\Tomcat\conf\server.xml

(Normally, you don't change this. But one reason it gets changed is because people don't want end users to see "AwareIM" in their URL - which is usually meaningless to an end user. )
Point is, if you browse this directory in Windows Explorer, thats the 'root' or top-level access point that Tomcat bases URLs from when logged in to your app.


2. Storing objects in the FS
Tell us where you are storing images.

You can store images anywhere you like, but Tomcat security only allows sessions to access files UNDER its "base" directory.
So if your images are in c:\UploadedDocs , then they have to be copied (by Aware) into a location that is accessible to Tomcat. This is why people see 'random' images appear in C:\AwareIM\Tomcat\webapps\AwareIM (but they don't get cleaned up).


3. From your browser, you should be able to visit:
yourdomain/AwareIM/images/AwareIMLogo.png
and you'll get the aware logo that is installed in a standard installation.

You can access any file under yourdomain/AwareIM/ as long as you know the path.


4. Your images
If you have a directory "UploadedDocs" here: C:\AwareIM\Tomcat\webapps\AwareIM\UploadedDocs
And you've uploaded 'cust-001-logo.png' via your app,
and thats where you FS Path is storing images, then using the example in #3 above,
you can access it in the browser here: yourdomain/AwareIM/UploadedDocs/cust-001-logo.png


5. I'm not going to go into this here, as its documented on the web, but if you want to keep you images "outside" the Tomcat structure,
(a. you may want them on a diff. drive)
(b. you may not want them "under" the aware install directory because it complicates upgrades)
you can LINK a directory under tomcat to your upload directory. A Symbolic link, I believe its called. Do your research.

This combines the methods from above by having the images anywhere on your hard drive, yet Tomcat sees them in the LINKed directory you created under Tomcat. The best of both worlds.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
srufini
Posts: 34
Joined: Thu May 23, 2019 11:23 pm

Re: Uploaded pictures in HTML Attribute

Post by srufini »

Jaymer, thanks a lot for the very extensive explanation.

I saw indeed tha pictures are copied into tomcat directory, but are they kept there forever?
I mean, I am using an external network drive as repository for all my pictures and all my attachments, because my server HD is limited and I want to keep the repository separate anyway.

If all those pictures are going to be copied in the tomcat folder anyway, this defies my concept, and I going to need a huge HD in the tomcat server, isn't?
And overall, what is the use of choose a filepath for an image in a file system, if they are copied at then end in the tomcat folder?

I am going to do some research to implement the point 5 indeed. Thanks!

However, it seems I would still have the trouble of having the pictures copied in the tomcat folder. Does it mean I have to manually delete them every once in a time?

Picture and attachments can be seen only by users authorized to access aspecific project.

Also that means that unauthorize user that have a link to the picture can see the picture, right?

Thanks again, Jaymer.

Sergio
Jaymer
Posts: 2454
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Uploaded pictures in HTML Attribute

Post by Jaymer »

I saw indeed that pictures are copied into tomcat directory, but are they kept there forever?
yep. one guy wrote a script to remove them.
or you can select and delete in Windows Explorer.
aware doesn't manage them.
(keep in mind that this issue goes back 10+ years. 6yrs ago or so Aware added images in FS. Recently added S3 storage.)

I mean, I am using an external network drive as repository for all my pictures and all my attachments, because my server HD is limited and I want to keep the repository separate anyway.
If all those pictures are going to be copied in the tomcat folder anyway, this defies my concept, and I going to need a huge HD in the tomcat server, isn't?

yes, if you used the default strategy.

And overall, what is the use of choose a filepath for an image in a file system, if they are copied at then end in the tomcat folder?
well, if your images were under Tomcat, they'd be served from their existing location. no copying needed.
you have a case where you wanted them somewhere else (diff. hard drive), so for most people, if they would have put them under Tomcat to begin with, they'd have never run across this.

I am going to do some research to implement the point 5 indeed. Thanks!
yes, Link directory is best solution.

However, it seems I would still have the trouble of having the pictures copied in the tomcat folder. Does it mean I have to manually delete them every once in a time?
The linked directory will be under Tomcat, so Tomcat thinks all is fine. But the images will really be in d:\UploadedDocs

Picture and attachments can be seen only by users authorized to access a specific project.
Also that means that unauthorized user that have a link to the picture can see the picture, right?

very true.
Tomcat doesn't require authentication to access a file.
You can use that link I suggested to access to the AwareIMLogo.png file from an incognito window, not even logged into your app.
Tomcat is just serving a file that was requested.
The public may not know the path to your attachments, but a logged in user will - anyone could see the path to an image on the screen.
If "project_001" was part of the path, it logical to assume there's also a "project_002" set of attachments as well.
So one user could guess at filenames to see what else is out there.

A safe way is just to append a random string (using aware's random function) to the filename and then its basically un-guessable.
The user uploads a file and you rename it.
A filename would become
d:\UploadedDocs\project1\PO1000_34Dth872yZ.png instead of
d:\UploadedDocs\project1\PO1000.png

You might post a new thread on the forum to get other suggestions. Something like "Suggestions for obfuscating filenames of uploaded files" might get you some feedback.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Post Reply