Wireless File Transfer Using Webserver on an Android Device (PDF ...

48 downloads 54423 Views 472KB Size Report
File transfer between two android devices requires Bluetooth, which is slow, or file ..... Once a Wi-Fi network has been established, the app will call the server's ...
International Journal of Innovative and Emerging Research in Engineering Volume 2, Issue 2, 2015 Available online at www.ijiere.com

International Journal of Innovative and Emerging Research in Engineering e-ISSN: 2394 - 3343

e-ISSN: 2394 - 5494

Wireless File Transfer Using Webserver on an Android Device Nataasha Raul a, Saumidh Mhatre b, Sanket Pawar b, Upendra Nagmallewar b a

Asst. Professor, Sardar Patel Institute of Technology, Mumbai, India b Student, Sardar Patel Institute of Technology, Mumbai, India

ABSTRACT: Now a day’s high speed file sharing among different devices belonging to different ecosystems is getting quite complicated. Certain Operating systems do not allow devices to share file with different Operating Systems. We have implemented “Android File Sharing” application which helps the user to transfer files between the android device, and any other device connected to the same wireless network. The user can browse the files, by pointing the browser to the local IP address generated by the app. The web interface also allows the user to upload files to the device on which the android app is installed. The main aim of our paper is to simplify the task of sharing files between different devices. Keywords: Webserver, Wi-Fi, Files, Android, Hotspot I. INTRODUCTION File Transferring is rapidly growing in the field of technology as the capability of devices to store files is increasing. The most direct way for transferring files between an android and laptop requires a data cable. File transfer between two android devices requires Bluetooth, which is slow, or file transfer apps that is required to be present on both the device. Also file transfer between an iOS and an Android is simply not possible due to the restriction of the iOS. This restriction between devices with different Operating Systems creates a problem for file sharing. To resolve these problems occurred during sharing of files, we have made an application that is required only on the host device that is running android. On the host device the app would basically contain a modified web server that would be able to access the files present on the host device. The web server will access all the files present on the host device and display it on a web page as links. To connect to the webserver we would be using Wi-Fi network. These days Wi-Fi networks are easily available. Even if a network is not available, Android devices come equipped with hotspot facility to create its own Wi-Fi network. II. . TECHNOLOGIES USED A. WEB SERVER A Web server uses the client/server model and the World Wide Web's Hypertext Transfer Protocol to serve web pages to the client. The HTTP protocol is a request/response protocol. A client sends a request to the server in the form of a request method, URI, and protocol version, followed by a MIME-like message containing request modifiers, client information, and possible body content over a connection with a server. The server responds with a status line, including the message's protocol version and a success or error code, followed by a MIME-like message containing server information, entity meta information, and possible entity-body content.[3] 1. Uniform Resource Identifier (URI): URI is basically a combination of Uniform Resource Locator (URL) and Uniform Resource Name (URN). URIs in HTTP are simply used to identify a resource. [3] 2. HTTP Request: A request message from a client to a server includes, within the first line of that message, the method to be applied to the resource, the identifier of the resource, and the protocol version in use. [3] 3. HTTP Response: After receiving and interpreting a request message, a server responds with an HTTP response message. The first line of a Response message is the Status-Line, consisting of the protocol version followed by a numeric status code and its associated textual phrase.[3] 4. HTTP POST and GET: The HTTP GET request method is designed to retrieve information from the server. The POST request method is designed to request that a web server accepts the data enclosed in the request message's body for storage.[3] 5. Form Content Types: The “enctype” attribute of the FORM element specifies the content type used to encode the form data set for submission to the server. The two content types are: a) application/x-www-form-urlencoded b) multipart/form-data.[4] 187

International Journal of Innovative and Emerging Research in Engineering Volume 2, Issue 2, 2015 B. Wi-Fi Wi-Fi (Wireless Fidelity) is a most commonly used term for IEEE 802.11 communication standards. It is designed to provide location-independent communication between computing devices using radio waves rather than cable infrastructure. Wi-Fi operates either in the 2.4GHz or 5GHz frequency bands. C. Wi-Fi Hotspots Wi-Fi hotspot is a feature provided on most of the android phones. It allows the phone to create a Wi-Fi network of its own, for the purpose of sharing resources from the phone. The hotspot tethering present on an android device allows it the features of a regular Wi-Fi, thus assigning an IP and other features required. The Wi-Fi hotspot created on an android device can support up to 8 devices simultaneously. Each device connected will be allocated a different IP address by the device itself. Wi-Fi hotspots are primarily used to share the internet connection of the phone with other devices. We have used the Wi-Fi hotspot on the phone as an alternative, if any Wi-Fi connection is absent. This allows the application to function in places even when a Wi-Fi network is not available. D. Android File System Android provides various several options to save persistent application data. It includes: 1. Shared Preference: To store private primitive data in key-value pairs. 2. Internal Storage: To store private data on the device memory. 3. External Storage: To store public data on the shared external storage. 4. SQLite Databases: To store structured data in a private database.[5] III. IMPLEMENTATION A. System Architecture

Figure 1. System Architecture As shown in Figure 1, our system consists of an android device with http server running on it and client device/s. The client need to use the IP address port number displayed on the android device to connect with the server. After connection is established, the server serves the files of that android device to the client browser. Then the client can browse through the files displayed. B. System Implementation To implement file sharing, we would be implementing a web server on the host android device. The app will first check if the device is connected to any Wi-Fi network. If it isn’t, it will ask the user’s permission to switch on Wi-Fi hotspot on the device. Refer Figure 2

188

International Journal of Innovative and Emerging Research in Engineering Volume 2, Issue 2, 2015

Figure 2. The application asking permission to switch on Hotspot Once a Wi-Fi network has been established, the app will call the server’s start() method to start the web server. The web server will then display the IP address of the phone along with a pre-defined port number, which is required to connect with the web server. The snapshot of the IP address that will be displayed by the application is shown in Figure3. The client needs to enter this IP address to access the web server. Once the IP address in entered in the browser of other device within the same Wi-Fi network, list of all the files and folders present on the host device will be displayed in the browser. Refer Figure 4. The IP address port number combination points to the root directory of the device. As the user browses through the folders, the URI changes accordingly, pointing to the directory currently being displayed. The content of device can be viewed by opening it on the browser. The content can be either files or folder. While browsing the contents of the URI particular selected file/folder is sent to server. The server accepts the URI and checks whether it is empty. If it is empty, it displays root directory in the html page. Else it checks whether the URI is folder or a file. If the URI points to a folder, it displays all the contents within the folder. If the URI points to a file, then the file is opened in the browser. The file can be downloaded by right clicking on it and choosing ‘Save As’ option. The file will be downloaded to target device.

Figure 3. The application displaying the IP address and port number on which the server is running 189

International Journal of Innovative and Emerging Research in Engineering Volume 2, Issue 2, 2015 Another module of this system is uploading files to the host device. The uploading of the files takes place through html form fields. While uploading files to a particular directory on the host device, the user is required to browse to that directory of the device. Then the user can select the file which is supposed to be uploaded to the above selected directory of the host device. The file data is captured using the enctype attribute, multipart/form-data. On the host device, the server checks for whether the method used to upload is either “PUT” or “POST”. It then parses body by calculating its size using “content-length” field of header. Now the server reads entire body and writes it to a Byte Buffer. The server then decodes the body by searching for parameter “filename” within “content-disposition” field of header. It then writes the file to the mentioned directory. After the uploading is completed, the webpage is reloaded to reflect the changes.

Figure 4. Web browser of other device displaying files present on the host device. IV. FUTURE SCOPE In future we will be implementing authentication using cookies. For authenticated users the value of the cookie would be set to true, so that when the users makes a requests to the server, the cookie would be validated first and based upon the value, desired page would be displayed. Moreover, we are planning to make the site responsive, so that it would be convenient to access on devices with small screens and also to have a directory chooser on the app, so that the host would have greater control over the files and folders being shared. V. CONCLUSION Using existing technologies we have been able to bypass the restrictions placed on file sharing by certain operating systems. Also by simply installing a web server on the host machine and using the power of android system, an efficient high-speed file sharing can be achieved. ACKNOWLEDGMENT We would like to thank our esteemed Prof. Mrs. Nataasha Raul for her constant support and motivation. Her guidance in understanding at various phases of this paper has been crucial. REFERENCES [1] Pradnya Mate, Snehal Dhamale, Pranita Ohal, Ruchi Pawar, “Peer To Peer Content Sharing On Wi-Fi Network For Smart Phones”.IOSR-JCE, Volume 10, Issue 5 (Mar. – Apr 2013), PP 06-09. [2] Waheb A. Jabbar, M. Ismail, R. Nordin, “Framework for Enhancing P2P Communication Protocol on Mobile Platform”. [3] Hypertext Transfer Protocol - HTTP/1.1, [Online]. Available: http://www.w3.org/Protocols/rfc2616/ rfc2616. html [4] Forms in HTML documents, [Online]. Available: http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4 [5] Storage Options | Android Developers [Online]. Available: http://developer.android.com/guide/topics/data/datastorage.html [6] NanoHttpd/nanohttpd· GitHub, [Online]. Available: https://github.com/NanoHttpd/nanohttpd

190

Suggest Documents