Michael Cochez

Assistant Professor at Vrije Universiteit Amsterdam

Advanced task TIES532 - RESTful web services

Goal

Learn more about RESTful APIs and how to use them. In this exercise the student needs to interact with two slightly similar APIs. This task also requires the HTTP POST method to upload files to a server. In order to be more memory efficient, streams need to be used. Further, multi-threading needs to be used in an attempts to speed up the copying process. This task is performed individually.

Prerequisites

The student must understand the exercises from TIES456, i.e. the student should be able to implement the basic exercises and understands the workings. HTTP post messages with multiple parts use MIME for encoding of the parts. Read about MIME on http://en.wikipedia.org/wiki/MIME especially about multipart messages. For this task, you can use any programming language except Java. So, for the language of your choice, you will have to find out how to call services and serve requests. If you have no experience with multi-threading in that language, find out how it can be done. Some programming languages are inherently single threaded, please document if this is the case.

Task

The goal of this task is to create a service which is able to back-up the user’s files from the mediafire service (http://www.mediafire.com/) to the sendspace service (http://www.sendspace.com). The student’s service only has to work in that direction and not the other way around because the sendspace service requires a paid subscription to be able to implement the service in the other direction. Your service is accessed through a (simple) website where the user’s credentials for both services can be provided and the process can be started. The user has to be informed about completion or failure of the process. Your service can be hosted on Heroku, AWS or another service of your liking.

The process should connect to both services and check which files and folders from the mediafire service are missing on the sendspace service. If a file is missing on sendspace, the file needs to be downloaded from mediafire and uploaded to sendspace in the right directory. Note that the file has to pass trough your server for this exercise (there are some options to avoid this, which would be a better idea. However, for the sake of this exercise you have to do it this way.). The process should search recursively in all directories. Comparing two files can be done by only using the file’s name. (Thus, if sendspace has a file with the same name in the same location, the file can does not have to be copied.) The actual copying (downloading/uploading) should be done in parallel.

The API descriptions can be found on the mediafire developers site and the sendspace equivalent.

Do not to buffer too much data. Use streams wherever reasonable. Especially while downloading whole files from the one service and writing them to the other one.

The final delivered task are 2 projects, programmed using the language of your choice (except Java). Try to follow a multi-tier architecture. The first project/package/namespace contains the classes (and libraries) used to communicate with the above mentioned services. This is the logic tier. The second project which contains the web site code, which is the presentation tier. Note that the mediafire and sendspace services function as the data tier of your service. See also http://en.wikipedia.org/wiki/Multitier_architecture.

Returning the task###

  • Both projects need to be pushed to a separate git repository.
  • Add the teacher (user name:miselico) as a collaborator to the repos.
  • Add a README.md file to the root of your repo in which you document your choices and the author name.
  • You need to arrange a meeting with the teacher to show the task.

Hints

  1. Do not use esoteric languages if you don’t want to handle their troubles. (think: finding help, googling errors, deploying, …)
  2. Make sure that your mediafire read and sendspace write methods are thread safe! This can be done by synchronizing correctly or avoiding concurrent access altogether. The latter one is most often easier to implement.
  3. You can assume that the user does not have duplicate file names in the directories. (Or just ignore them if they are there)
  4. Think about how you design the class structure. Do not put all the code inside one class/method. (you could consider having classes/interfaces like MediaFire, SendSpace, WebFolder, WebFile, …)
  5. You are free to use libraries as you see fit. Use the dependency management tool suitable for the language you choose.
  6. Error checking should be implemented up till a reasonable extend. (Check HTTP status codes and API return values.) When an error is found, you do not have to write extensive handling of the error. (No retry, no alternative strategies, etc…) Just show an error message to the user. Do not let the whole application die when a normal exception is thrown though.