how to upload and then download files from application using Glassfish 4.1.1 and jelastic? - glassfish

I was trying to upload and download files at application level using jelastic server in cloud and I have some issues during downloading the uploaded files
to upload the files I use:
File folder = new File(".." + File.separator + "customFolder");
and the files are uploaded correctly inside of:
/opt/GlassFish/glassfish/domains/customDomain/customFolder/
and I can see the files using jelastic dashboard and ssh
but, if I try to download them through application I have a 404 error
using this kind of approach
Link
I try to use the instructions posted here
Cann't get file from classpath (using NIO2)
but this doesn't work for me. Also I try to use some paths also posted in jelastic documentation (https://jelastic.zendesk.com/hc/en-us/community/posts/206122066-Uploading-Files-to-a-Specific-Folder) but noticed there is no a clear explanation for Glassfish.
Also I figure out that the files are in different locations inside of jelastic application folders
these are the different locations that I have found and tried to use to downloading the files (I changed the access permissions, also without making a successful download):
/opt/GlassFish/glassfish/domains/customDomain/customFolder/
/opt/repo/versions/4.1.1/glassfish/domains/customDomain/customFolder/
/opt/shared/glassfish/domains/customDomain/customFolder/
so my question is
what is the correct path to download the files or should I change the upload path?
an example using java code returning the string with the path for download would be appreciated
I'm using Glassfish 4.1.1 for the application

Related

The issue with downloading files with Selenium with Jenkins

Testers may have this issue for sure.
Assume that we have a testcase that should be automated. And it has a step to download a file from the webpage by clicking a link and it will be downloaded to our local machine’s download folder. As the next step it should be verified that the file is downloaded.
So in a local machine this can be handled easily by using the download paths and all. But the matter that I have is this exact same testcase is getting fail in Jenkins (cloud run). It returns a null value because the download directory cannot be found in Jenkins.
Do you guys know what kind of solution that can we take for this? I heard something using API request to download the file. Yes this file is also getting downloaded by a GET request with parameters. But I don’t know how to perform that.
Thanks for your time.
I tried the bellow options.
Changing the directory to Windows and Linux as per the documents
By using jenkins home directory
What I want to do?
to verify that the file is downloaded
Read the file and check with the db (This has existing methods)

How do I fix Directus error code 3 when downloading stored files

I can store files to the specified storage location via the GUI. I can see the files are in the storage location.
When I try to download them using the GUI, I get this every time.
{"error":{"code":3,"message":"Unauthorized request","class":"Directus\\Exception\\UnauthorizedException","file":"\/var\/www\/directus\/src\/helpers\/app.php","line":287}}
When I try the links from the File library, I get the same error.
I found some old topics concerning a "_" project. I do not see any "_" entries in my project.php configuration.
Everyone has read permissions for the storage directory.
The rest of the system appears to run without error.
check the folder in the server and what is been set, the default should be, like
So then if you want to access the 300x300 the URL should be like:
domain.com/public/uploads/Directus/generated/w300,h300,fcrop,q80/file-name.jpg

Why do I have to delete my build and dist files to successfully upload a new version of a package to Pypi?

I get a 400 client error file already exists if all I do is change the version number in setup.py
My program is just a "hello world".
Some friends told me to delete build and dist and then it works but I couldn't find anywhere else on the internet why this is. All the tutorials I came across kind of just hand waved updating or said changing version number with bump version would allow this.
I'm assuming you're using twine upload dist/*. By default, this will tell twine to upload everything in the dist directory. However, if you're already uploaded some of these distributions, you won't be able to upload them again.
Instead, you can either specify the exact distribution you're trying to upload:
twine upload dist/yourproject-1.0.0.tar.gz
Or use the --skip-existing flag:
twine upload --skip-existing dist/*

File Upload.Go Ahead Webserver

Right now, i am working on a go ahead embedded web server. i have an old 2.1 version of this server, which was open source. i want to upload .json file which i create from the firmware, to the web server and then want the page to process that file using flot tool,and display a graph.but that version does not support file uploading capability. on internet i have found that the new version of this web server support the file upload capabilities, but i have not found a proper example which explains the syntax that i would use to upload the file. can any one tell me which functions of this new version i would have to use to get things working.
can any one give a proper full example.
You ask how to upload using goahead.
When you build the source, it should build a test executable called goahead-test. This uses test/test.c as a main program. Test.c defines an upload action handler that is invoked when you do a file upload to the url /action/uploadTest. This handler will echo back to the browser the various file upload details. You can cut/paste from test.c into your own main program.

How to change the path that jar files use in java Web Applications

I have written a java Servlet web application, using NetBeans 7.2.1. The program have some jar file libraries that I have attached to the project. The application runs fine using NetBeans and Apache Tomcat 7.0.27.
My problem is that some of the jar file libraries that I am using in the project, need to access to some folders and files. I put these folder and files on the same directory as the whole NetBeans project is. but I got this exception:
Exception: java.lang.RuntimeException: java.io.FileNotFoundException
So I used these codes to find out where should I put them:
out.println("current directory: " + new File(".").getAbsolutePath());
out.println("current directory: " + System.getProperty("user.dir"));
out.println("current directory: " + getServletContext().getRealPath(("/")));
So I figured out that the current working directory is:
C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.27\bin
My question is that how can I set different directory address for each web application? I have many web applications and some of them use the same resource file names. I can't just put all of them in one directory.
Please note that I don't have access to the source code of jar files to change the. I just need a way to set the absolute path that the jar files use.
I have the same problem when I put the WAR file on the unix server. The extracted WAR file is in this location on the server:
/data02/tools/Apache/Tomcat/apache-tomcat-6.0.37/webapps/BANNEROnline
But I figure I should put the resource folders and files in this path (moosavi3 is my username!):
/home/moosavi3
How can I change the path?
The working directory is the directory from which java.[exe,bin] is started. I assume the bin directory is where the tomcat start-up script is? If the jars are all using this working directory I don't believe there is a way to make different web-apps have different working directory, they're all loaded on the same jvm (java.exe) from the same working directory.
A working directory is the directory from which a binary is started, it is not some arbitrary value that you can change.
I suspect these jar files where meant to be run as standalone applications and expected the filesystem resources they are trying to access to be in the same location as themselves.
Any filesystem resources would have to be moved to the location of your java.exe so that the correct file path resolution can result from your jars.
Standard Servlet project requires external libraries to be placed in the 'WEB-INF/lib' directory under project root. You can search google for 'servlet directory structure' and do your own research for more information. Shared libraries between web applications can be placed in the 'lib' directory under tomcat root, they should be picked up by tomcat jvm. My recommendation would be to keep the dependencies project specific, because you may need different versions in different projects in the future.
Update:
Read this page on the tomcat documentation, it will explain exactly how the project should be structured, and how to add a library that will be shared across all web applications:
http://tomcat.apache.org/tomcat-7.0-doc/appdev/deployment.html
Update 2:
The following Stackoverflow link explains several options how to add a static file to your web application, that will available at runtime.
https://stackoverflow.com/a/2161583/940754
Update 3:
Add a path to the classpath using the project's manifest:
http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html