BITS Upload Sample
Summary
This sample demonstrates a simple application that uses BITS to upload
files to a IIS server using the HTTP protocol. BITS allows for
file transfers that consume only 'idle' bandwith and that are automatically
restarted after interruptions such as network outages, machine reboots
or user logoff.
The UI for the Upload Sample captures text entered by the user, and
packs it as an XML file. This XML file is in turn uploaded to the IIS server.
If the check box Process a reply from the server after the completion of the upload job
is checked, and the file is uploaded to a virtual directory that has BITS Extensions
notification enabled, then the app will receive a reply from the server, and will
display its content in the Job Status area.
Key Concepts
- Basic connection with BITS job manager and submission of BITS jobs
- Registration of a job callback for special handling of errors and job states
- Submission of Upload and Upload-Reply jobs
- Configuration of the IIS virtual directory for Upload and Upload with notifications
Build/Configuration instructions
- Run "nmake" in the directory where the sources are.
- Change the current directory to the binary output directory in the SDK.
- Run the configuration script, by executing "cscript configure.js <physicalpath_root_for_virtualdirectories>".
Execute only "cscript configure.js" to obtain usage information.
- Execute uploadsample.exe.
Basic Usage
Upload
- Select http://localhost/UploadSample in the Upload file to the following virtual directory combo-box
(or type the URL for a virtual directory with BITS Extensions enabled).
- Type some words in the Pack the following text in an XML file edit box.
- Click the Upload file button.
- Check if a file with a name in the format "uplxxxx.xml" was uploaded to the UploadSample virtual directory.
Upload-Reply
- Select http://localhost/UploadSampleWithNotifications in the Upload file to the following virtual directory combo-box
(or type the URL for a virtual directory with BITS Extensions enabled, and Notification settings adjusted
to execute the ASP script newupload.asp).
- Type some words in the Pack the following text in an XML file edit box
- Click the Upload file button
- Check if a file with a name in the format "uplxxxx.xml" was uploaded to the UploadSample virtual directory
- Check in the Job Status area if a reply was received from the server
System configuration
- To be able to compile this sample, your system needs the Windows Server 2003 version of the Platform SDK (Core SDK).
- In order to execute uploadsample.exe, your system needs BITS 1.5 client installed in the client machine, and
BITS 1.5 server in the server machine.
BITS 1.5 (server and client) is included with Windows Server 2003. No action is needed to enable the client part of the BITS software.
For the server part, you might need to enable BITS Extensions in your IIS 6.0 server. To enable BITS Extensions
in a Windows Server 2003 system, use the following steps:
- Go to Add or Remove Programs
- Select Add/Remove Windows Components
- Select the Application Server check box, and
- click Details
- Select the Internet Information Server check box, and
- click Details
- Check the Background Intelligent Transfer Service (BITS) Server Extensions check box, and click OK
- Click OK twice to close the previous dialogs
- Click Next to proceed with the Windows Components Wizard
- Click Finish when it is done
- For Windows 2000 and Windows XP versions of BITS 1.5, there is a redistributable package available at the Platform SDK
download web site.
Questions
For development and deployment questions on BITS 1.5, please post a message to the newsgroup
microsoft.public.windows.backgroundtransfer, or contact Microsoft Support.
Known issues are commonly published as Knowledge Base (KB) articles. Please go to
http://www.microsoft.com/support and search using the term "Background Intelligent Transfer Service".