Media Part Implementation

Uploading file

This week, I mainly completed the implementation of Media part, including uploading file, downloading file and making directory. And I was starting to code for Chat. So for the rest of the work are Chart part we will get our first version. (even there is login part as well, but quite small part)

According to Dan’s uploading tutorial, I finally learned how to upload a file. I used to do file uploading by coding for both client and server by using Base64, but I’ve never coded for a just client, so it’s a little tricky for me. But in fact, I just need to put the file content in payload of HTTP, and boundry it with something.

In order to pick a file to upload, I used a OpenFileDialog to explore the files of Android client. When a file is clicked in OpenFileDialog, the CouchDB.upload is executed to upload it to current directory. And the same dialog is used for choosing a direcotry for the file to download. When a file in the Media fragment, the dialog is shown for choosing a directory, and when “select this directory” is clicked, the downloading process is started.

As for making directory, it’s pretty easy. But it’s a little tricky when I create a file in root direcotry, because instead of using null or empty string for parameter dir, no parameter dir should be passed to server.

The images shows the dialog:

1> Choose a directory to download file:


2> Choose a file to upload:


3> Make a new direcotry:




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s