JavaFX - file (video) upload - java

I asked this question before but it was unanswered for a week or so I think so I decided to ask again but with a different formula.
I have a JFX desktop app. one of the features of one of the modules contains a video upload to the server. I searched this around a lot but the solutions I found are in two categories
using servlet / jsp on the server and service in the desktop app
copying the file locally (not what I want)
now I am ok with havign a service doing it the upload that's what I expect but I dont see the need of having a deployment on the server plus I already have a webapp. Is it possible to just have a webservice in the server and call it in the desktop app code? I haven't found anything on this.

Yes, it's possible and preferable choice.
The potential solution I see would be:
deploy a file REST service on your File server where the videos would be held.
Example Rest service in Java: https://github.com/polopolyps/fileserver
Then in your java FX application you simply send user file (a video) using REST lib, see: http://square.github.io/retrofit/
and Voila you have your functionality.

Related

Java web application with S3 File Manager

I am working on a web application based on Java/JSP and I need to include a web based file explorer that connects to an Amazon S3 bucket that can handle the basic file explorer tasks such as upload, delete, rename and navigation. Any suggestions would be appreciated.
have you tried simply creating a wrapper to wrap around s3cmd ? that would be the ultra lazy way to do it. since then all the protocol handling is done for you and all you have to do is feed/parse its input and output
S3cmd is extremely well documented and pretty simple to use.

80mb Image/Video uploading to cloud storage / blobstore

I am a C# developer who recently decided to venture into the mobile dev world specifically android dev using java. It has been a smooth ride until now. While I'm usually able to follow the tutorials on the android developers site and other sites easily, uploading an image/video to the app engine blobstore or cloud storage seems to be a bit over my head. I cant seem to wrap my head around the process.
I have already done the necessary steps to get my app running on app engine. I am able to register devices and save basic entities to the cloud but I cant seem to get any of the tutorials to work form me.
Basically my app allows users to take images or videos and then have them posted to my back end as part of a file sharing type of game.
I am not asking for someone to give me code that can accomplish this, instead pointing me to a very thorough tutorial would be great!
1.I need understand the role of a servlet (most examples use this for uploading to blobstore)
2.Where should the servlet reside?
3.Is there another way to do this without using a .jsp page for the file uploading ?
4. I have set up the app engine back end for my project including endpoints. Is there a way to send the images/video that way to the server and still be able to retrieve a serving url to fetch the image/video later?
I have been stuck on this for a week now and I'm getting quite discouraged as I cannot seem to adapt any of the tutorials that I have read to suite my needs. There are a few dark spots in my mind where the entire process is concerned. Since I am not familiar with java, servlets etc I'm stumbling in the dark and I just need a lamp to light my path. I think i'm just a step or two away.
BTW I have looked at these questions and tried the code suggested to no avail before deciding to post my own.
Upload to Appengine Blobstore in Android
BlobStore vs Cloud Storage for storing user uploaded images
Upload image from Android to Google Cloud Storage or Google App Engine Blobstore
Please help!
NOTE: I don't have an interface where the user gets to choose the image/video as it is to be taken directly from the camera and sent to the server(not sure that makes a difference).
You need to do a lot more reading. First understand servlets in general. Then learn how to use the blobstore or cloud storage api. Then read how to post directly to blobstore (not to the servlet) with a post-save servlet callback.
Welcome to the world of Java!
I'll try my best to explain the Servlets/JSPs part. I dont know a whole lot about Google app engine.
1) Servlets are nothing but Java objects but with more priveleges. Servlets know how to handle a web request! There are many things that come to mind when we talk about web request processing:
who maps the URL to this servlet?
Who gives this servlet user request parameters?
How can I guarantee only authorized users can access this servlet?
list goes on......
Answer to all above questions is a web container. And in the world of Java only one web container rules (others might differ): Apache Tomcat.
In short, servlets are Java objects created for you by Tomcat.
Where should the servlet reside?
They reside in Tomcat.
Is there another way to do this without using a .jsp page for the file
uploading ?
You dont need a JSP to send requests to a servlet. You can use jquery, python or anything else. As long as its a valid web request.
I have set up the app engine back end for my project including
endpoints. Is there a way to send the images/video that way to the
server and still be able to retrieve a serving url to fetch the
image/video later?
See the tutorial here. Especially 'Implementing Tweet My Picture' section.
Google app engine has Java API (along with python) and the best way to submit web request to that API using Java is servlets. That's why many example are in servlets. I think.
Here's what i would do if I were you:
Setup tomcat. There are many options. So reply if you are not sure.
Deploy your handler servlet that'll use Google app engine Java API.
Send your image files to blobstore (not the servlet). See the tutorial. App engine will forward blob related information to the handler servlet you created in step 2.
Use Blobstoreservice in that servlet so that users can access that uploaded image.
Let us know if this helped.

Is It Possible to Convert Regular Java Applications to Web Applications?

What i mean by this question is that can people start a .jar application embedded on web or they have to download it ? I made a simple online game and people nowadays will not want to individually download the game instead of directly accessing it through the browser. I developed the game on desktop, which steps should i take to make it a web application, or can it directly be converted to a web application ?
If you don't want the user to download the entire application then you must recode it using web technologies.
If you want your answers be able to launch the application via their browse (which involve the download of the application "transparently") you can just make an Applet like #huseyin tugrul buyukisik said or you can use Java Web Start : http://docs.oracle.com/javase/tutorial/deployment/webstart/
You can wrap your classes in an applet, just add a button to launch the class.
init() method will be overloaded to load the classes, start() method is to launch things. Applet is single thread so if you launch expensive loop in one of the overloaded methods, applet can stuck. You can need threads.
There is no direct conversion from jar to web application. Web servers wouldn't understand this. what you need is to
create a web application folder structure, copy jar to web-inf\lib folder
prepare web.xml as required for your application
bundle web application folder into a war file or deploy it exploded
Typical web application folder looks like:
webapp
|-*.html,*.images, *.js, *.css
|-WEB-INF
|-WEB-INF/web.xml
|-WEB-INF/lib/*.jar
|-WEB-INF/classes/*.class, *.properties
The major change in this scenario IMO would be change in routing of request to web-server instead of approach taken by your desktop app i.e. single JVM, calls directly routed to handler class instance.
Say a hypothetical case, upon save from a GUI the desktop app might be serializing data to local disk, now in case of web application it might be required to send this data to web-server (say specific SaveServlet) which takes care of this logic at server machine instead of clients.
If you provide specific usecase of your desktop app functionality, we might be able to help better.
you can do this using jnlp (java native language plugin), which will be download automatically when user visits your page (even by providing link for the same).
After that it will ask user permission to execute that jnlp (same as a jar) & your jar will be executed at the client side.
http://www.mkyong.com/java/java-web-start-jnlp-tutorial-unofficial-guide/

calling swf function from java (without loading swf file into browser)

I searched a lot regarding this topic but did not get any good answer.
Scenario:
We have Rest web service bases implementation in our project. Ideally frontEnd (Flex) call web service and backend send huge data point to frontEnd. Then frontEnd create chart of these data points and display to end user.
Our requirement is that user can export these charts and save as pdf file on the server. We are able to create JPG file from flex server and save as pdf file.
Problem occurs when end user has scheduled that chart report. Now that report can run at any time and may be browser is not opened at that time. So how backEnd will interact with frontEnd (flex) functions. Problems are:
browser is not opened so swf file is not loaded.
java/jsp need to interact with frontEnd(flex) as a reverseAjax so that frontEnd send JPG file back to server.
Does anybody face this issue before?
Is it somehow possible??
Asnwers/any leads are highly appreciated.
Please provide comments on this
Probably the only way to do this is to run a version of your Flex application (at least the charting part) on your server, and have your Java server interact with it.
I have faced a similar problem and have asked a similar question before. It is not very elegant, but what I mentioned before seems to be the only way to go.

HOW-TO: remote file access from a web server?

We have a web application which which is deployed and used within an intranet. The application reads in text files from a specified location on the web server itself.
Now we have a requirement of reading in text files from other machines as well, so i'm exploring possible options to implement this. Possible options i've been thinking of are:
Maybe start a ftp server on each local machine and then write a servlet to ftp given machines n read-in data.
Maybe run some utility program thats would read in file contents and push it back to the server using xml etc ?)
Ne help about above/or new ideas would be highly appreciated!
Technologies i'm using are :
Tomcat/Struts/JSP/AJAX.
P.S i want to handle non NFS situations as well!
Thanks,
Abhishek.
apart from the fact that I don't know whats the purpose of the application you're building, and knowing it is a Web-app, why not have users upload the specific files you want to process?, or even better, if they are configuration files, you might put them all in one single location, let's say just one machine. That might be better than having your app stuck just because some machine is not accessible.
I have an idea for you.... You may expose web service on each machine where from you want to get logs.These web services will read log files and send to your web application in bytes. You web application will call these service periodically and will take latest data. your entire system would work like a distributed system. you need to ensure that log file should generate with the name in uniform format - for eg.. log-24-12-2010.log or log24122010.log (if your log file generates on daily basis) - so that web services can form the right name of log and access it.
I recommand you to use RESTful web services because they are pretty easy for such purposes. Use JAX-RS APIs to develop such services.
I hope you would get my idea a little bit.
~~ Priyanjan

Categories

Resources