Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
maxLevel3
minLevel3

About the sample

This sample demonstrates a file upload/download/preview application with the use of several features available in the WSO2 Data Services ServerWSO2 Enterprise Integrator (WSO2 EI). Some notable functions are listed below.

  • Streaming Support : With the data streaming functionality, when a service client makes a request, the result is streamed to the service client rather than building the full result in the server and returning it. This allows virtually unlimited payload sizes in the result, and the response is instantaneous to the client.
  • Binary Data : Binary data is handled using Base64 encoding to store and retrive non-textual data, such as data files and BLOB fields in databases.
Service description

The sample data service used here (FileService) transfers and retrieves file data between the client and a database. The list of queries used by the data service to carry out the actions are as follows.

...

By combining functionality of the above queries, we can create a sample file management system with the use of data services. See About Data Services and Resources for a definition of data services, queries and operations.

Building the sample

The sample data service, FileService should be deployed using the instructions in Samples Setup.

Running the sample

To execute the application, you have to run the ant file_service_app command as described in the Data Services Clients section. 

  • Uploading files
    When uploading files, after a file is selected to be sent, the file is read and the data is transferred in chunks to the server. Figure below shows a file upload in progress.
     
  • Downloading files
    Select a file you want to download from the file list and press download. After selecting the path to be saved, the file data is retrieved from the server and saved on the local disk. When the user clicks download, the data download starts immediately as indicated by the progress bar. This is possible because of the data streaming capability of the WSO2 Data Services Server.
     
  • Previewing files
    Images can be previewed using this application. Select an image file and click Preview. The image is downloaded to memory and shown in the preview panel:
     
  • Deleting files
    To delete a file from the server, select the file name from the list and press Delete. This invokes a data service operation and removes the file from the database.