How to set the file upload path in liferay portlet so that it can be stored either in unix or windows system(machine independent)? - liferay

The suggestions were giving the path as catalina_home or user/home.
Do I need to set any parameters in server.xml?
And using actionRequest.getPortletSession().getPortletContext().getRealPath("/"); I am unable to store the file path in database.

Properties properties=PortalUtil.getPortalProperties();
String serverHome = properties.getProperty("liferay.home");
//To get the liferay server home folder
create any folder for uploaded files under it.

Related

Website is not loading styles and files because is loading a different path

I just published my web app which has the following structure:
Project Name
StylesFolder
filename.css
anotherfile.css
JavaScriptFolder
bootstrap.js
Index.html
What I did was:
Adding a new WebSite in the server IIS with the path were I publish my WebApp (ex. C:\WebProjects\PublishedApp\Project Portal)
Selecting my published app and converting into an application (The alias name was Project Name and the physical path was C:\WebProjects\PublishedApp\Project Portal\Project Name)
The problem is when I try to see the website. I'm able to enter to 192.169.100.20:80/Project%Name/ and my index page is loaded (I can see the text, inputs, etc.) but I cannot see any stlye and javascript input and when I check the console logs all the files are getting a 404 error response.
When I check which URL is used by the files I can see that they are trying to get accessed by 192.169.100.20:80/Project Name/StylesFolder/filename.css etc...
So my question is what can I do to remove the /Project%Name/ string from the URL?
PD. I'm using IIS 7
When you add your website in IIS, select the application folder you published. For example, when you publish your application to D:\Program Files\Publish Folder, select the Publish Folder folder directly when adding the website and choose the physical path.
This is the reference:Deploy Website on IIS

Server MapPath not working on remote server

I am using Server.MapPath to find the path for a document uploaded to a remote server, so that I can then open it. However when using it, it is returning a relative path and so rather than searching the remote server it is searching the local machine instead.
What I am using to open the document is:
System.Diagnostics.Process.Start(Server.MapPath(Path.Combine("~/", document)));
Where "document" is the part of the path relative to the document itself, in this case "Files\2016\11\doc_name". So I want to take the path of this document, go to the top level of the site, and then find the document from there.
However I would hope that this would return a path similar to "server\inetpub\site\Files\2016\11\doc_name" but instead it is returning a path like "d:\inetpub\site\Files\2016\11\doc_name".
Can someone help me with what is the correct function to use to get the path I need?
EDIT
I have managed to fudge together the correct path using the following code:
string server = Environment.MachineName;
string path = Server.MapPath(Path.Combine("~/", documentpath));
System.Diagnostics.Process.Start(#"\\" + server + path.Substring(path.IndexOf(#"\")));
However, while I can get this to access the file when I'm running the project locally, it errors when I try to do it on the published site. As I can access it in one way, I'm assuming that it could be permissions (just to note the site is using windows authentication). Is this the most likely cause?

Lotus Notes : properties file couldnt not be found and loaded

I am new to lotus and I am trying to pull the properties data from the server in Java Agent and I am getting error that file is not found and one thing is if I use ff.load method it is giving error as cannot access properties file.
Can any one tell what I have to add it in this code such that it would work correctly. I have corrected restriction rights also. and select the second option
Java Code.
InputStream con = session.getClass().getResourceAsStream("C:/pqrs.properties");
if(con== null)
{
System.out.println("FLAG FILE NOT FOUNDFIND NOT FOUND!!!!!!!!!!!");
}else
{
System.out.println("FLAG FILE FOUND !!!!!!!!FIND FOUND");
}
Properties ff = new Properties();
ff.load(con);
The OS's filesystem security settings are probably not allowing the Domino server to read files from the root directory of the C: drive.
Try moving the file into a location that you know for sure that the Domino server can read. E.g, the C:\IBM\Lotus\Domino\Data folder - or whatever the equivalent location is in your Domino server's configuration.

Cant access images one directory back

I am using linux server and I am using absolute path for files which is stored in a "constant"
File path is
/home1/mousi1/public_html/xyz/data/1465221530.png
Image is loading when I access file which is on home directory like
/home1/mousi1/public_html/xyz/file.php
but when I try
/home1/mousi1/public_html/xyz/subdirectory/file.php
Path is still
/home1/mousi1/public_html/xyz/data/1465221530.png
but image is not showing I am wondering why is it?
What is wrong?

DLFileEntryLocalServiceUtil.getFileAsStream(...) not working in liferay server

DLFileEntryLocalServiceUtil.getFileAsStream(...) not working in my server I have s3 configuration for document and media. This method perfectly working without any issue in local server where s3 not configured. Does this require any extra configuration.
I basically want to convert DLFileEntry into File so I had used another method.
File file = DLFileEntryLocalServiceUtil.getFile(user.getUserId(),dlFileEntry.getFileEntryId(), dlFileEntry.getVersion(), true);

Resources