2. File Delivery
To deliver a file, there are three models:
Direct linking
Delayed linking
OMA Download
You can use any of these three methods to deliver the files,
either using the physical file (video, audio, game, etc.) directly or
via a script (PHP, ASPX, etc.). If you use a script to deliver a file,
you can log, secure, and even charge for every download. If the file is
available directly through the web server, anyone with the URL can
download the file.
Note:
The installation of files using HTTP is also called OTA
(Over-the-Air) provisioning. Some low-end devices don’t have a web
browser but do have the ability to download files (e.g., ringtones,
applications, or images) using HTTP. We can offer files to those
devices, but we must send the download URLs by WAP Push using
SMS.
2.1. Direct linking
Direct linking is the simplest way to deliver content. A
direct link is just a link to the file (with the right MIME type
defined), a link to a script that will deliver the file, or a link to
a script that will redirect the user to the file. For example:
<a href="game.jad">Download This Game</a>
<a href="download.php?id=22222">Download This Game</a>
The download.php script can
save the download to the database, check permissions, and then deliver
the content using the appropriate MIME type, writing the file to the
response output or redirecting the browser to the file:
<?php
if ($everything_ok) {
header('Location: game.jad');
} else {
header('Location: download_error.php');
}
2.2. Delayed linking
Delayed linking is a technique often used in download
sites for desktop browsers. It allows us to show a landing page before
the download starts. This landing page will also be the document the
user will see after the download has finished or, if the browser
supports background downloading, while it is downloading.
Note:
Some devices also look for the type attribute in a link to decide how to
manage the link before downloading the response from the server. For
example, we can define a link as a Java ME JAD file using:
<a href="game.jad"
type="application/vnd.sun.j2me.app-descriptor"> Download This Game</a>
The technique involves linking to an XHTML document that will
show the user some information and will use a refresh metatag to redirect the user to the
direct link in X seconds (more than 5 for mobile
devices).
So, the download page will redirect to:
<a href="download.html">Download This Game</a>
And download.html will
contain code like the following:
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="refresh" content="5;game.jad" />
<title>Download File</title>
</head>
<body>
<h1>Your game is being downloaded</h1>
<p>If the file is not downloaded in 5 seconds,
<a href="game.jad">click here</a>
<h2>Brought to you by "Your favourite ad here"</h2>
<p>Trouble downloading this game? <a href="sms:611">Send us an SMS</a>
<a href="tel:611">Call Us</a></p>
<a href="/">More Downloads</a>
</body>
</html>
2.3. OMA Download
OMA Download is a standard defined in 2004 by the Open
Mobile Alliance to allow us more control over the delivery of media
objects. It also has support for Digital Rights Management (DRM) in
two versions, OMA DRM 1.0 and OMA DRM 2.0.
Note:
Many browsers support the download of Multimedia Messaging
Services (MMS) templates using
a format called the Synchronized Multimedia Integration
LanguageNokia tools available at http://www.mobilexweb.com/go/mms. (SMIL). This is useful if you are offering
templates like postcards. You can create messages using
OMA Download adds two phases to the download process:
before download and after
download.
The before download process involves a description file
downloaded using HTTP before the real file is downloaded. This
description file is an XML file containing metainformation for the
operating system and instructions for doing the download. This process
gives the user an opportunity to see information about the content
(name, compatibility, size) before accepting it, as shown in Figure 1.
Note:
Using OMA DRM you can protect a file from being sent by MMS,
Bluetooth, or any other method after it has been installed on the
device. This is to avoid piracy of video, music, Flash Lite, and
other multimedia content. Nokia, Sony Ericsson, and Motorola devices
are known to have support for this standard.
The after download process involves an HTTP request posted to
your web server from the operating system, confirming the final status
of the download. This allows you to confirm that the file has been
correctly downloaded and installed.
OMA DRM supports the ability to define the right to play,
display, or execute a media object or a file a limited number of
times. DRM should be managed with care, and you need to test
compatibility with the devices you’re targeting before using
it.
Note:
Sprint, a U.S. carrier, uses a similar format called
General Content Descriptor (GCD). A GCD file is a text file with a
.gcd extension that is very similar to the JAD
file in Java ME.
2.3.1. Download descriptor
The descriptor is an XML-based file that should be served
using the MIME type application/vnd.oma.dd+xml.
Here’s a simple example of this file:
<?xml version="1.0"?>
<media xmlns="http://www.openmobilealliance.org/xmlns/dd">
<name>The first man on the moon</type>
<type>video/mp4</type>
<objectURI>http://mobilexweb.com/video.mp4</objectURI>
<size>230</size>
<installNotifyURI>http://mobilexweb.com/download/notify.php?id=3333
</installNotifyURI>
</media>
These are the typical attributes: name, the user-readable name of the
content file; type, the MIME type
of the file; objectURI, the
absolute URL of the file; size,
the file size expressed in KB; and installNotifyURI, the URL that will
receive the after-download status (this can have GET parameters defined dynamically to log
whether or not the download was saved).
Additional properties are also available, like nextURL (the URL of a website to visit
after the download has finished), description (a short description of the
media file), vendor (the organization providing
the file), and iconURI (an
optional icon to be shown with the file information).
Note:
There are good resources and tools on the Forum Nokia, Sony
Ericsson, and Adobe websites about OMA Digital Rights Management.
You can find more information at http://www.mobilexweb.com/go/drm.
2.3.2. Post-download status report
If you define the installNotifyURI in the download
descriptor, you will receive a POST request to that URL when the download
finishes. This URL will receive as the POST body an integer code with a status
message. The important thing is that this request does not come in
the normal URL-encoded way, so you can’t use the typical $_FORM or Request.Form. To read the status code,
you’ll need to read the request body in a low-level format. Table 1 lists the most common OMA
Download status codes to read in our scripts.
Table 1. OMA Download status codes
Code | Message | Description |
---|
900 | Success | The object was
downloaded and installed. |
901 | Insufficient
Memory | The device has no
space to download or install the file. |
902 | User
Cancelled | The user cancelled
the download. |
903 | Loss of
Service | The device lost the
network connection while downloading the
file. |
905 | Attribute
Mismatch | The file doesn’t
match the download descriptor (e.g., the MIME type). The
file will be rejected. |
906 | Invalid
Descriptor | The download
descriptor is invalid. |
951 | Invalid
DDVersion | The download
descriptor version is invalid. |
952 | Device
Aborted | The device aborted
the installation process. This can occur for different
reasons. |
953 | Non-Acceptable
Content | The device cannot use
the file. |
954 | Loader
Error | The URL of the file
is not working. |
To read the OMA Download response from a PHP script, you can
use the following sample code:
<?php
// We get the post body from the input
$post = file_get_contents('php://input');
// We get the first three characters without spaces
$status = substr(trim($post), 0, 3);
if ($status==900) {
// Download OK, save information to the database
} else {
// Some error happens, save information to the database
// to allow the same user to download it again
}
?>
If you are delivering premium content that the user has paid
for, if the download fails you should deliver the same content
without forcing the user to pay again. Even if the download has
succeeded, many carriers insist that the content be made available
free of charge for 24 hours (or even up to a week). Some new
application stores also allow the users to download the premium
content again even if they change their mobile devices.
Note:
Remember that you can check for OMA Download compatibility
using WURFL, DeviceAtlas, or another library before using this
download mechanism.
Table 2
reports on browser compatibility with OMA Download.
Table 2. OMA Download compatibility table
Browser/platform | OMA Download
compatibility |
---|
Safari | No |
Android
browser | No |
Symbian/S60 | Yes |
Nokia Series
40 | Yes |
webOS | No |
BlackBerry | Depends on the
device |
NetFront | Yes |
Openwave
(Myriad) | Yes |
Internet
Explorer | Depends on the
device |
Motorola Internet
Browser | Depends on the
device |
Opera
Mobile | No |
Opera
Mini | No |