This documentation is for WSO2 Data Services Server 3.0.0. View documentation for the latest release.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Current »

This sample demonstrates a file upload/download/preview application with the use of several features available in the WSO2 Data Services Server. 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.

The sample data service FileService should be deployed using the instructions in Deploying Data Services section.

Running the Sample

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

Service Description

The data service transfers and retrievs 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.

  • createNewFileQuery: Creates a new file given the file name and the type.
  • appendDataToFileQuery: Appends new data to a given file. By sending in file chunks, data streaming can also be done while sending the data.
  • deleteFileQuery: Deletes a file when the file name is given.
  • checkFileExistsQuery: Checks if a file with a given file name exists.
  • getFileRecordsQuery: Returns all data records associated with a specific file.
  • getFileNamesQuery: Returns the names of the files in the database.
  • getFileTypeQuery: Returns the file type of a given file name.
  • getFileSizeQuery: Returns the size of a given file name.

By combining functionality of the above queries, we can create a sample file management system with the use of data services.

Sample Run

Uploading files

When uploading files, after a file is selected to be sent, the file is read and the data 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 pressing download. After selecting the path to be saved, the file data is retrieved from the server and saved on local disk. When the user clicks download, the data receiving 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 app. Select an image file. When you click preview, the image is downloaded to memory and shown in the preview panel as follows:

Deleting files

To delete a file from the server, select the file name from the list and press the delete button. This invokes a data service operation and removes the file data from the database.

 

  • No labels