How To Write A File Station In Android.Com (For Free) On A Microsoft Macbook Or Ipad (For A Limited Time) On An Ubuntu 8.1 (For Ubuntu) On Your Computer Or Ipa (For



Similar documents
Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department. Mobile Computing ECOM Eng. Wafaa Audah.

ID TECH UniMag Android SDK User Manual

Android Development. 吳 俊 興 國 立 高 雄 大 學 資 訊 工 程 學 系

Android Environment SDK

Cloud Storage Service

Installing the Android SDK

How To Run A Hello World On Android (Jdk) On A Microsoft Ds.Io (Windows) Or Android Or Android On A Pc Or Android 4 (

Android Setup Phase 2

See the Developer s Getting Started Guide for an introduction to My Docs Online Secure File Delivery and how to use it programmatically.

Android Development Setup [Revision Date: 02/16/11]

Qsync Install Qsync utility Login the NAS The address is :8080 bfsteelinc.info:8080

OpenCV on Android Platforms

Android Environment SDK

HTTPS hg clone plugin library SSH hg clone plugin library

Login with Amazon Getting Started Guide for Android. Version 2.0

Hello World. by Elliot Khazon

Basic Android Setup Windows Version

Developing for MSI Android Devices

Application Development Setup Guide

Global TAC Secure FTP Site Customer User Guide

With a single download, the ADT Bundle includes everything you need to begin developing apps:

How to develop your own app

Android Programming. Høgskolen i Telemark Telemark University College. Cuong Nguyen,

Android Development Tutorial. Nikhil Yadav CSE40816/ Pervasive Health Fall 2011

Spring Design ScreenShare Service SDK Instructions

Download and Installation Instructions. Android SDK and Android Development Tools (ADT) Microsoft Windows

Setting up Sudoku example on Android Studio

Mobile Solutions for Data Collection. Sarah Croft and Laura Pierik

Tutorial on Basic Android Setup

Step by Step. Use the Cloud Login Website

User Guide Trust Safety Accounting Upload PC Law and SFTP Software Release: Final Date

Xopero Backup Build your private cloud backup environment. Getting started

SDK Quick Start Guide

TECHNICAL NOTE TNOI27

Oracle FLEXCUBE Direct Banking Android Tab Client Installation Guide Release

Introduction to Android Development

What you will need before beginning this guide

Advantages. manage port forwarding, set breakpoints, and view thread and process information directly

Remote Storage Area (RSA) Basics

How to setup camera with NAS

NovaBACKUP Remote Workforce Version 12.5 Cloud Restore

Secure Messaging Server Console... 2

CafePilot has 3 components: the Client, Server and Service Request Monitor (or SRM for short).

Remote Access: Citrix Client Setup

7. Mobile Phone Support

Technical Support Set-up Procedure

Capture Pro Software FTP Server System Output

Developer Guide. Android Printing Framework. ISB Vietnam Co., Ltd. (IVC) Page i

Download and Installation Instructions. Android SDK and Android Development Tools (ADT)

CRYPTOGRAPHY 456 ANDROID SECURE FILE TRANSFER W/ SSL

Developing In Eclipse, with ADT

Mocean Android SDK Developer Guide

Advanced Digital Imaging

UP L18 Enhanced MDM and Updated Protection Hands-On Lab

Lab 0 (Setting up your Development Environment) Week 1

IOIO for Android Beginners Guide Introduction

VoIP Softphone for MAC

Customer Tips. Xerox Network Scanning HTTP/HTTPS Configuration using Microsoft IIS. for the user. Purpose. Background

Bitrix Site Manager ASP.NET. Installation Guide

ANDROID APPLICATION FOR FILE STORAGE AND RETRIEVAL OVER SECURED AND DISTRIBUTED FILE SERVERS SOWMYA KUKKADAPU B.E., OSMANIA UNIVERSITY, 2010 A REPORT

Android Application Repackaging

IIS, FTP Server and Windows

Fahim Uddin 1. Java SDK

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Document From MAXIMUM BUSINESS INFORMATION TECHNOLOGY ON A. OwnCloud User Manual. TO I Cafe`

NAS 206 Using NAS with Windows Active Directory

Board also Supports MicroBridge

How to connect to the University of Exeter VPN service

Getting Started: Creating a Simple App

Android: Setup Hello, World: Android Edition. due by noon ET on Wed 2/22. Ingredients.

NOTE: Please refer to the LinkNavigator CD-ROM s IP Setup Utility if you do not know the LinkStation s IP Address or Host Name.

Document OwnCloud Collaboration Server (DOCS) User Manual. How to Access Document Storage

Android App for SAP Business One. Z3moB1le App Version 1.00 Pagina 1 di 12.

WHMCS LUXCLOUD MODULE

IRF2000 IWL3000 SRC1000 Application Note - Apps with OSGi - Condition Monitoring with WWH push

Android, Bluetooth and MIAC

Introduction to Mobile Access Gateway Installation

Internet Address: cloud.ndcl.org

DCH File Transfer Application User Manual

Arduino & Android. A How to on interfacing these two devices. Bryant Tram

Upgrading the DVR System Firmware EH1116H-4 series EH6000H series. Quick Guide

PC Monitor Enterprise Server. Setup Guide

SFTP Server User Login Instructions. Open Internet explorer and enter the following url:

Having Fun with QNAP and your Home Automation

How to Join QNAP NAS to Microsoft Active Directory (AD)

How to configure the TopCloudXL WHMCS plugin (version 2+) Update: Version: 2.2

Contents First Time Setup... 2 Setting up the Legal Vault Client (KiteDrive)... 3 Setting up the KiteDrive Outlook Plugin Using the Legal Vault

How to build your first Android Application in Windows

Tutorial on OpenCV for Android Setup

DSI File Server Client Documentation

Installing and Configuring vcloud Connector

Using Internet or Windows Explorer to Upload Your Site

SeaSmart Firmware Update via FTP

Developer Guide: Android Object API Applications. SAP Mobile Platform 2.3 SP02

Primavera P6 Professional Windows 8 Installation Instructions. Primavera P6. Installation Instructions. For Windows 8 Users

NAS 208 WebDAV A Secure File Sharing Alternative to FTP

EasyPush Push Notifications Extension for ios

LICENTIA. InvoiceXpress Integration

Web Testing, Java Testing, Server Monitoring. AppPerfect Installation Guide

Transcription:

QtsHttp Java Sample Code for Android Getting Started Build the develop environment QtsHttp Java Sample Code is developed using ADT Bundle for Windows. The ADT (Android Developer Tools) Bundle includes: Eclipse + ADT plugin Android SDK Tools Android Platform-tools The latest Android platform The latest Android system image for the emulator You can download ADT Bundle from Android developer website. http://developer.android.com/sdk/index.html And you can read how to setting up the ADT Bundle on website. http://developer.android.com/sdk/installing/bundle.html Open project Unzip sample code zip file, Open Eclipse and select a workspace at unzip folder. Now you can see Qsample in you worksapce. Basic settings Open AndroidManifest.xml Min SDK version is equal 9 Uses Permission includes android.permission.internet and android.permission.write_external_storage. 1

User Interface Login When you execute this sample code, the first page is login page (Fig. 1). After you type server ip, port, use SSL, user name, and password, click Login button. Wait a short time, then you can see NAS share folder list (Fig. 3). Display NAS s file list It will show the file list in the folder that you click it (Fig. 4). Display device s Download folder file list Click Upload to here button, it will show /mnt/sdcard/download folder s file list (Fig. 6). Download file In Fig.4, if you long click file 1.jpg, the file will be downloaded from NAS to device s Download folder on SD Card. The progress dialog will be showed (Fig. 5). After download file successfully, you can see the file in Download folder (Filg. 6) Upload file In Fig. 7, go in to a NAS folder like /Public/CCC/qqq. If you want to upload file to here, click Upload to here button, long click file 1.jpg (Fig. 6). The progress dialog will be showed (Fig. 8) and the file is uploading. After upload file successfully, you can see the file in NAS folder (Filg. 9). Logout If you want to logout NAS, click Logout button, and it will go to show login page. 2

Fig. 1 Fig. 2 Fig. 3 Fig. 4 Fig. 5 Fig. 6 Fig. 7 Fig. 8 Fig. 9 3

QDK and App The sample code includes two parts, QDK and App. QDK QDK provides the basic function of QNAP NAS. It is easy to expand function because it is high modular. In this sample code we provide six File Station s functions. Package: con.qnap.qdk.qtshttp Class/Interfance/Enum Description QtsHttpServer It represent QNAP NAS and it be used to create File Station QtsHttpServerInfo Save server information QtsHttpSession Keeps File Station connecting information QtsHttpStationType List station type QtsHttpConnection Be used to execute URL QtsHttpResponse Be used to return URL response content and response code QtsHttpCancelController Cancel controller IQtsHttpTransferedProgressListener Interface of transferred progress listener Package: com.qnap.qdk.filestation Class/Interfance/Enum IQtsHttpFileStation QtsHttpFileStation QtsHttpFileEntry QtsHttpFileStationApiVersion QtsHttpFileStationStatus Description Provide several File station functions Implement File Station functions Be represented a file/folder List file sation api version File station status Package: com.qnap.qdk.exception Exception QtsHttpException QtsHttpAuthorizationFailedException QtsHttpFileExistException QtsHttpFileNotExistException QtsHttpNetworkConnectionFailedException 4

QtsHttpNetworkNoConnectionExceptioin QtsHttpNewtorkTimeoutException QtsHttpNoAuthorizedException QtsHttpParameterInvalidException QtsHttpPermissionDeniedException QtsHttpServerDisconnectException QtsHttpServerNotExistException QtsHttpStationNotEnabledException QtsHttpSystemOutOfMemoryException Package: com.qnap.qdk.parser Class/Interfance/Enum JsonParser Description Json parser Package: com.qnap.qdk.util Class/Interfance/Enum StringTranslator Description Support encode password and URL preprocess functions App App includes UI (User interface) and behavior control. Package: com.qnap.qsample Class/Interfance/Enum MainActivity EntryList LocalList Description Login page Display NAS file list and provide file uploading/downloading Display local file list in SD card s Download folder 5

Functions Login to File Station 1. Create serverinfo object and set server information like host name, user name, password, using SSL conection, and computer name. String serverip = "192.168.0.1"; String username = "admin"; String password = "admin"; String agentname = "QtsHttp"; String computername = "PC"; boolean isssl = false; SSLQtsHttpServerInfo serverinfo = new QtsHttpServerInfo(serverIP, username, password, isssl, computername); 2. Create a server object based on QtsHttpServer using serverinfo object. QtsHttpServer server = new QtsHttpServer(serverInfo); 3. Setup connection Non-SSL/SSL port. server.setfilestationsslportnum(443); server.setfilestationportnum(8080); 4. Use server.login() method to login File Station. server.login(qtshttpstationtype.qts_http_station_type_file_station); 5. Use server.openfilestation() method to get filestation object based on IQtsHttpFileStation. public static IQtsHttpFileStation filestation; filestation = server.openfilestation(); 6. Now you login into File Station and get filestation object. Get share folder list In QNAP Turbo NAS, the root folders are called Share folder. If you want to get the share folder list, use filestation.getsharefolderlist() method to get the share folder list. It will return ArrayList<QtsHttpFileEntry>, and you can get type (folder/file), name, path, and file size from each QtsHttpfileEntry. 6

1. Create cancel object based on QtsHttpCancelController. QtsHttpCancelController cancel = new QtsHttpCancelController(); 2. Get ArrayList<QtsHttpFileEntry> and use for loop to get each QtsHttpFileEntry. ArrayList<QtsHttpFileEntry> fileentrylist = filestation.getsharefolderlist(cancel); for(qtshttpfileentry fileentry : fileentrylist) { String filename = fileentry.getfilename(); String filepath = fileentry.getfilepath(); boolean isdir = fileentry.isdir(); 3. If you want to cancel getting share folder list, you can set cancel.setcancel(). cancel.setcancel(); Get forder and file list If you want to get the file list in folder, use filestation.getfilelist() method to get the file list. It will return ArrayList<QtsHttpFileEntry>, and you can get type (folder/file), name, path, and file size from each QtsHttpfileEntry. 1. Create cancel object based on QtsHttpCancelController. QtsHttpCancelController cancel = new QtsHttpCancelController(); 2. Set parent path, index of ordering file list, number of getting file entry String parentpath = /Public/ ; int index = 0; int limit = 50; 3. Get ArrayList<QtsHttpFileEntry> and use for loop to get each QtsHttpFileEntry. ArrayList<QtsHttpFileEntry> fileentrylist = filestation.getfilelist(parentpath, index, limit, cancel); for(qtshttpfileentry fileentry : fileentrylist) { String filename = fileentry.getfilename(); String filepath = fileentry.getfilepath(); boolean isdir = fileentry.isdir(); Download file 7

If you want to download file from NAS, you need to get source file path (from NAS) and destination file paths (to your device). You also need to implement your TransferedProgressListener class implementing from IQtsHttpTransferedProgressListener. So you can show the progress on you app. 1. Implement your TransferedProgressListener class implementing from IQtsHttpTransFeredProgressListener. You need to override onprogress() method. public class TransferedProgressListener implements IQtsHttpTransferedProgressListener { private long mtotalfilelengthinbytes; public TransferedProgressListener() { mtotalfilelengthinbytes = 0; @Override public void onprogress(long transferedfilelengthinbytes) { if (mtotalfilelengthinbytes > 0) { long percentage = Math.round(((double)(transferedFileLengthInBytes * 100) / mtotalfilelengthinbytes)); Message msg = new Message(); Bundle data = msg.getdata(); data.putlong("percent", percentage); msg.what = smsgupdateprogress; msg.setdata(data); uimessagehandler.sendmessage(msg); public void settotalfilelengthinbytes(long totalfilelengthinbytes) { this.mtotalfilelengthinbytes = totalfilelengthinbytes; 2. Setup source and destination file path. Create cancel controller and transferred progress listener. String downloadsrcfilepath = /Public/test.txt ; String downloaddestpath = /mnt/sdcard/download/ ; 8

QtsHttpCancelController cancel = new QtsHttpCancelController(); TransferedProgressListener proglistener = new TransferedProgressListener(); 3. Download file. filestation.downloadfilebypath(downloadsrcfilepath, downloaddestpath, 0, cancel, proglistener); Upload file If you want to upload file to NAS, it is similar download file. You need to provide source file path (from your device) and destination file path (to NAS). And you also to implement your TransferedProgressListener class like download file or you can use same TransferedProgressListener from download file. 1. Implement your TransferedProgressListener class implementing from IQtsHttpTransFeredProgressListener. You need to override onprogress() method. 2. Setup source and destination file path. Create cancel controller and transferred progress listener. String uploadsrcfilepath = /mnt/sdcard/download/photo.jpg ; String uploaddestpath = /mnt/sdcard/download/ ; QtsHttpCancelController cancel = new QtsHttpCancelController(); TransferedProgressListener proglistener = new TransferedProgressListener(); 3. Upload file. filestation.uploadfilebypath(uploadsrcfilepath, uploaddestpath, cancel, proglistener); Close file station 1. Using server object to close file station first. server.closefilestation(filestation); filestation = null; server = null; 9

Expand functions This sample code just implement six function includes login(), logout(), getsharefolderlist(), getfilelist(), downloadfile(), and uploadfile(). You can get File management API document (QNAP File Station Web API document) for QNAP Developer Center website: http://www.qnap.com/dev/en/ Go to Resource, and download Development tooklkit (API & SDK) File management API document. You can read this document and implement other functions. 10