How to find the path of the uploaded files on Weebly? - java

I'm trying to make my own website using Weebly. I want to include a Java Applet I made and therefore I must use an HTML snippet on the website. In the snippet I have to include the path of my uploaded Applet in order for it to run. How can I get this path, because I do not know where the files end up after uploading them. I saw in one post that each user gets a very specific path with each upload but how did they find this out? Is there a way?

not sure if you still need an answer to this....the path for uploaded files into your weebly site (via the Design Tab, then "edit HTML/CSS" menu is "/files/theme/yourfilename.js"

Weebly by default gives it's subdomain sites the ability to control content so when you upload anything to weebly via Code Editor (Weebly main -> Design -> Edit Html/CSS -> Add New Files)
the default address is
yoursubdomain.weebly.com/files/theme/filename.extension
For example if my file name is social-grey and is png extension and my subdomain is geniusknight ( http://geniusknight.weebly.com ) then the link would be:
geniusknight.weebly.com/files/theme/social-grey.png
Similarly for Javascript extension with name test would be
http://geniusknight.weebly.com/files/theme/test.js
and make sure in the source use the complete url and not the short ones like test.js because that doesn't work in subdomain sites for weebly.

Go to Design > Edit HTML/CSS > Assets folder.
Go to the image or file you'd like to reference and grab the URL.
e.g. http://www.weebly.com/editor/uploads/3/4/0/9/34091/custom_themes/647127941726820885/files/homelogos/codehs.jpg
To use a relative path instead of an absolute path, remove everything before /uploads...
e.g. /uploads/3/4/0/9/34091/custom_themes/647127941726820885/files/homelogos/codehs.jpg
Hope that helps!

Go to Weebly then design and edit html.
Left click a pre existing .png image, then in that same window right click over the image that pops up and go to open image in new tab.
In the new tab you will see the address in the address bar. It will look something like this...
weebly.com/uploads/6/9/2/1/12851110/custom_themes/138585217722419571/files/yilogo.rar?1407684265479
You can drop the ?1407684265479 bit to have a direct url for your file!!!!
weebly.com/uploads/6/9/2/1/12851110/custom_themes/138585217722419571/files/yilogo.rar
Then replace that file name in this case yilogo.rar with the file you have just uploaded or wish to use from your existing collection. E.g.
weebly.com/uploads/6/9/2/1/12851110/custom_themes/138585217722419571/files/flags.exe

Related

Downloading a local file

Files is stored in this location.
D:/uploads/component.png
This is the HTML code to download a file.
<a target="_blank" href="../{{att.filePath}}"><strong>{{att.fileName}}</strong></a>
But when I click on the link it opens up as in this path, which is wrong as it is not in the server.
http://localhost:9190/D:/uploads/component.png
How can I see the file in web browser, what am I doing wrong here.
Though you are not showing your variables' contents, it seems your variable contains the absolute path for the file. Therefore you don't need to add relative parts (e.g. ../) to the path.
Also, if you want to host a file for downloading, you must make it available inside the hosted directory (document root). You can achieve this in multiple ways:
A) Simply copy the file/directory into the document root. Then you can also use relative links if you wish (you have to change the variable!).
For example, you may have a structure like this:
public_html/
uploads/
component.png
index.html
Then you can link the file in index.html using the absolute path /uploads/component.png, or using the relative path uploads/component.png.
B) Create a symbolic link to the file/directory inside the document root.
For example if you create a symbolic named uploads in your document root for your D:/uploads/ directory, you will have this structure:
public_html/
uploads/ -> D:/uploads/
index.html
This way you can still have the file physically at D:/uploads/component.png but it will be available also in public_html/uploads/ and you can use the same paths as in method A).
C) If you are developing a webapplication (it seems so, as you tagged Java and Tomcat), there is another option. You can define a controller method which maps requests like /uploads/* and implement it so it will read the file specified by the URI from your D:/uploads directory.

create folder with app icon instead of default folder icon

I want to add my app Icon to created folder instead of default folder icon.
I know i can create folder with following code.
String extr = Environment.getExternalStorageDirectory().toString();
File mFolder = new File(extr + "/My Application/Downloads");
if (!mFolder.exists()) {
mFolder.mkdirs();
}
By doing this, i'm getting following result.
but what i want is..
I have searched a lot, but no luck. can anyone help me out?
Thank you.
Directories do not have icons, and so whatever app or tool your screenshot is from is adding that. You would have to ask the developers of that app or tool what algorithm they are using to determine the icon to show.
Customization of folder icon is OS dependent.
On Windows you will use Desktop.ini file to assign a custom icon or thumbnail image to a folder. To simplify working with Desktop.ini you can use ini4j. Basically, you will need to create Desktop.ini in the folder, that you want to customize and specify path to the icon there. (Here is similar question)
On Mac OS the process is different. There are ways to access icons (for example, FileView or FileSystemView, also Quaqua). However I haven't found a way to set folder icon programmatically with Java.
Note: I assumed, that you want to add icon to arbitrary folder and not your app laucher.
After creating new directory you have to declare resource directory in your gradle file so that android studio can recognize new resource directory.
More information please refer https://developer.android.com/studio/write/add-resources

How to give path to the PDF file while creation in struts 2?

I am trying to create a PDF file using struts 2.Action class location is as follows.
/home/Jagan/MATCH/Jagan/src/ActionClasses/PDFFile.java
Here workspace starts from
/MATCH
In PDFFile.java.I am writing as given below and it is working fine.
pdfwriter=PdfWriter.getInstance(document,new
FileOutputStream("/home/Jagan/xyz.pdf"));
But i have to create this under the folder
/home/Jagan/MATCH/Jagan/PDFs
I should not use /home/Jagan/ as it will become hardcode if i have to run this application in other system.
I tried
pdfwriter=PdfWriter.getInstance(document,new
FileOutputStream("../../../PDFs/xyz.pdf"));
But it is not creating file.Even if it works it is not feasible solution (because "../../../" does not work in windows ).
Please suggest me a good way to specify path for creating file.
Adding to the question.
I have to provide download option for downloading this created file in JSP page.Which struts tag should i use. Please provide me syntax for that
downloading files has 2 aproaches:
1. you can return it with outstream result like is explained here
2. as you are trying to save the file first at filesystem then access it from another url.
Answer to your question is you should get servletContext.getRealPath("/WEB-INF"), and after that everything is relative to WEB-INF.
I should not use /home/Jagan/ as it will become hardcode if i have to run this application in other system.
Correct, Use following instead
System.getProperty("user.home");///home/Jagan/, it will return you path to your home dir

File Explorer - Altering File/Folder associated icon programmatically

Have you noticed modifications to the icons associated with files and folders when using file explorer in windows/linux while having a svn client installed (e.g., TortoiseSVN). Basically, when a folder is saved in a SVN repository, normally there is a tiny green tick icon added to the associated file icon. I want to know how TortoiseSVN/Dropbox/... do this and whether I can achieve similar results using Java6 JDIC ?
Thanks,
-A
Those are called "icon overlays" in Shell jargon. Here's a start:
http://msdn.microsoft.com/en-us/library/cc144123(v=VS.85).aspx
-scott
This should help you out..
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/jdic_assoc/
org.jdesktop.jdic.filetypes.Association
The Association class allows
programmers to create new file types
or edit existing ones. The class
includes methods to edit the file
extension type, the MIME extension
type, the icon that goes with the file
type, and the actions that are
associated with the file type.associated with the file type.

Image not showing in src tag

Can anybody tell me how do i give absolute path of the img tag's src attribute?
The following doesn't work
<img alt="NO IMAGE" src="/home/administrator/tiger-info0[1].gif"/>
I am working On Ubuntu and i am very sure that image exists on this path.
This is probably happening because the image is located outside the web server's document root.
Your web server will not be able to serve anything from outside the document root. One possible workaround is to use a scripting language that has access to the file system, and route the images through the script. For example, you may want to check out the following implementation in php:
Serving Images Outside Document Root Via PHP
You can also create a symbolic link of /home/administrator/ into the document root:
ln -s /www/yoursite /home/administrator
hmm why don't you copy the image to your web directory and give it the relative path? you server (apache?) may not be able to access the file to serve the browser.
if you are making a local html page you can use that path but if you are creating a website you have to use the absolute path to the document root. And make sure the image path is correct (use firebug)
Give your path correctly with domain or use ../ or ./ is for to represent correct relative path.
You cannot access files that are not in your document root. Get Java application server to not delete your folder. You can probably do this by having one folder into which your users can upload files, and add that folder to your project. You can let users create subfolders inside that main folder, and since the main folder is a part of your project, cleaning the build will not automatically delete it or its subfolders.

Categories