Process of uploading to a server - java

There doesn't seem to be a comprehensive explanation of the exact process being undertaken for uploading files from an android device to a server. So far I have pieced together some information on the methods for preparing the data however the "plugging in" if you will is somewhat more confounding.
What is it that is absolutely necessary for the transaction to take place? What information is required on the app side and what is the server looking for? How does the server get the data without first being preprogrammed to receive it?
I feel that simply setting up a ftp server is not enough so I'm wondering what else is involved. Any help for a novice would be gladly appreciated, thank you.

Related

Want to transfer information contained in a database in one iteration of an app to another iteration on a different phone

I consider myself an accomplished programmer, but I'm relatively new to Android App development. I'm creating an application that will store information into the SQLite database used in Android. What I'd like to be able to do is be able to take a query of that data and export it either as a file of some sort or just send it to another iteration of the same application on a different phone. Then be able to have that phone import the same information into its own database, seeing that the information should line up correctly as long as it keeps it.
Can anyone provide some good starting examples of how I would best go about this and/or tutorials on how to go about doing it? Right now I'm just not sure how to get started and I could use some help to push me in the right direction, so I'd really appreciate the help.
Thank you ahead of time to anyone who replies.
and export it either as a file
depends on what kind of data you have. You can write any kind of text-based data using a RandomAccessFile for example.
send it to another iteration of the same application on a different
phone
You will need to have your own backend to do so. You could identify the target device by using GCM

How would I go about Transfering data between JAVA and PHP?

I have a java application that has information that I need to display on a webpage, sorta like a chat room, The way I'm currently doing it is by having the java application listen for connections on a specific port and then I have a PHP script that connects every second to update the information listed on the page, What I'm trying to find out is there a better way of doing this? I haven't done anything like this before so sorry If this method is really stupid, I'm just looking for the best way to accomplish this. All constructive comments are welcome.
EDIT:
I forgot to mention that I'm doing this over TCP and I do not have access to MySQL so I can't store anything In a database then have the PHP script go and retrieve it..
Well it depends strongly on the flow, when should the communicate? If PHP needs data from Java then just do a call and parse the data back in xml's. Else if it is a lot like a chat, there should be a way to socket it, although I have never tried it.

Android app, how to log into website and display information?

I'm trying to build an android app that will log into a website, scrape the website for data specific to the user, then format that data nicely on a mobile screen.
I've noticed that there are several similar questions to my own, and after reading some of the documentation, I am still very confused as to how I should go about this.
Here's what I know
The site that I want to log into utilizes asp.net and the login.aspx uses POST for the login form.
There is no API for this website
There is also no single sign on
I'm very new to Android and a novice JAVA programmer at best. Will someone please help me carve the path of research that I need to do in order to write this app? I feel that I mostly need help with connecting to the website and getting the data, I'll be able to figure out the layouts and formatting myself.
I am more than willing to research and read whatever is necessary, but I would like to minimize any irrelevant information that would ultimately lead to more confusion.
Thank you in advance for the help
For the purpose of accessing the website all you need to know about is HTTP. It doesn't matter whether your target website is built with PHP or ASP etc. As you're only concern is how to communicate with the website through HTTP which is independent of technology used by the website. You can try wikipedia for descriptions of these methods.
It might be worthwhile reading the Java URL tutorials for how to use Java classes. As regards extracting the data itself you might want to read up on Parsers. This link might give you some first ideas.
I'd use the Jsoup
API. I've posted many many threads on that issue. This'll probably help you login. I don't know how android manages SSL certificates. So that you'll have to research on your own. But this right here is a good start.
Jsoup Cookies for HTTPS scraping

Problems with PHP connecting to a Java program using a Port

Hoping someone can shed some light on this.
I have a PHP program which opens a port and sends some text to a java program listening on that port. Basically, there could be many instances of this PHP program connecting over this port to this one java program. The java program contacts an API, retrieves the answer, and then sends the information back over the port to the PHP program.
This solution seems to work but sometimes I get a empty response in my PHP program. The java program runs run successfully but the answer string is not transmitted back through the port to the php program.
Does this solution sound valid? Will I ever have an instance where the java program will send back the wrong information to the PHP program? Can anyone see any problems here? Thanks a bunch!
"Opens a port" is ambiguous, I'm going to assume you mean "opens a TCP connection".
There's no reason that the scheme you outlined cannot work, but you haven't provided enough information to narrow down the cause of the problem you're having.
When your PHP script gets an empty response from your Java code, it could be because the connection was broken, but it's more likely that the code on one end or the other has a bug. Make sure you're testing all the result values for errors.
If you need help finding the problem, you will need to post more specifics, ideally the smallest example of real code (for both ends of the connection) you can get to exhibit the problem.
Does the Java program close or at least flush the socket's stream after writing?
Consult the basic Sun tutorial "All About Sockets" for details and proper code examples.

Large file uploads with Java applet

I've been tasked with implementing large (2gb+) file uploads via a web browser. After evaluating various technologies, java applets seem to be the way forward (only one's which provide proper access to the local disk). I was wondering if anyone can recommend a 3rd party file upload app we can use as a base? requirements are
Decent UI, ideally we want something similar to facebooks photo uploader
Can handle large (2gb+) files
Resumable uploads
We beed the source to extend it to our needs (dont mind paying extra)
You're probably looking for JUpload.
Update: not sure if it has as nice of UI as you're hoping, but unless you want to build a custom solution like I have it's your best option.
Just a tip, maybe it is obvious, i don't know :P
It is nice to send the big file in chunks like 2mb, and on the server side you just append the bytes to the target file. The server knows what bytes it needs, and if a upload is aborted and continued later, the server can just send a message about from what bytes to start uploading the file again. Then we get resumability (is it a word? :P) and safety of large HTTP-uploads (since, in fact, we are sending many smuller uploads, and each upload is checked to be of the correct size on the server).
We wrote an implementation like this once with a Java-applet as the client and PHP on the server, I'll see if I can dig it out as a reference for you :p
Not really a solution : from experience you may bump into the following issues:
problems when uploading over HTTPs
problems uploading through proxies
Just wanted to make you aware of these two cases, for you to test when evaluating a solution.
Hope, you will get solutions for your prob over here.. http://jupload.sourceforge.net/

Categories

Resources