Tag Archives: File Upload

File Upload A Success (on a real phone!)

I finally got the upload proof-of-concept application to work on my Ion! As it turns out, the problem was actually the registration page for the university wireless network…

There is a redirect page the first time a new device is connected to the network, which requests some simple information like a name and email address. This page was apparently being loaded behind the scenes in my application, and giving me some strange errors (file IO errors for the website) in the ddms log. I likely would never have discovered that this was the problem, had I not opened up the actual web browser application, as was suggested by this post on Google’s Android Beginners.

Basically, the suggestion found there is to try to access your file upload page in the normal browser (even though that application disables file uploads!) to confirm that you can actually access the page from the phone. I know it saved me a ton of time, so I definitely recommend using this technique Smile

Uploading Files from Android (progress update 2)

Right before I left the lab yesterday, I uploaded from the Android Emulator to Octopussy successfully. Daniel was here, he’s my witness.

Today, it doesn’t work, which is super awesome. It isn’t a matter of computer goblins or anything like that though, the Android Emulator was running a pseudo-SD card which I had manually pushed my test file onto. That is the only thing that changed from yesterday to today, so something has gone wrong with the file system. I’ve been making some attempts to get away from using the SD cards for my testing, because it is a bit unpredictable.

I wrote some code to generate files based on user input, but I’m getting the same crashes from that as I do from the SDcard version. I have a feeling it has something to do with file permissions, because when I browse the emulator’s file system with DDMS, the permissions on files I’ve pushed are all weird and different from other ones on the phone. I started having some issues yesterday with command line sdcard management, and I switched to direct code/DDMS options, which is probably why it is acting all weird.

Once again I’m really hoping I can get it up and running soon! It was really exciting to see it run successfully yesterday, and pretty disappointing to have it crash today 🙁

Uploading Files from Android a success! (locally)

Shortly after my last post I actually had a pretty major breakthrough with the upload proof of concept. I managed to get my Android application (running on the emulator) to upload a file to a server on my local machine. The PHP approach to the problem ended up being the way to go. I added a post to this thread which had been confusing me for about a week. Tons of people posted saying “it worked” or “this is the client side code that worked”, but nobody simultaneously posted the PHP and Client-side snippets which worked for them.

I found the XAMPP server application very helpful as I worked on doing the initial proof of concept. It creates a server on the localhost of your machine, so you can test web code without actually deploying it on a server (which is a whole other set of headaches-the ones I currently have!). One little gotcha that Carny helped me fix is that the permissions on the directory you want to upload to – they need to be such that your ‘server user’ has permissions to write to that directory (or just chmod 777 but be aware that this is NOT the good/secure way to do it – it works if you just need to test it and set it back afterwards though).

Another interesting thing I learned today was how to add a faux-SDCard to your android emulator. Just run the commands on that site in a terminal (from your tools directory). In order for the file upload to work, you need to manually push the file to your Android’s SD Card!

Also, please note (and I’ve forgotten it twice already since learning it in that tutorial…) that the directory path given in that link is NOT what you want to put as your own eclipse path. It looks deceptively like some super-secret google pathname, a G: drive, Android, SDK_Root, etc. However, this is just the path that the creator of the tutorial happened to have on his PC. You need to insert the path to the sdcard you create!

My next task will be to get the file upload working from a real Android phone to an actual server. I’ve been working on getting the uploader.php to run on Octopussy, but so far I’m getting errors. The PHP that I set up seems to be working fine though, which is nice to see. Hopefully by tomorrow I’ll have it all up and running!

Uploading Files from Android (progress update)

After I left the lab last night I realized I haven’t posted as to my activities in a while…

Basically, I’ve spent the past week+ researching various methods of achieving this task. I’ve looked into using CGI, JSP, and PHP for the server-side of the code. I had to scrap my CGI/JSP attempts as I couldn’t find any client side / server side code that meshed well (or tutorials to help me figure it out). I’ve been looking into a thread on using PHP, and it seems a lot more promising. I hope to have some results to show for all of this effort soon.

As a neat little side project (for when I need to take little breaks away from this upload thing), I’ve been working on that pseudo-tethering thing you can do with gphones and netbooks. I think it’d be useful for those of us with gphones to be able to (ab)use our 3G to get internet on our laptops where there isn’t any wifi. My last attempt at getting it to run crashed and burned though, so I’m going to go back to that one some other time.