BITS UPLOADS Sample
Summary
This sample
demonstrates the usage of BITS APIs to upload a file.
BITS allows uploads of single files to a remote IIS server. The server must be
preconfigured to accept those uploads. An example of
how to do that can be found in the \web\bits\upload sample. You can also find
the specific requirements for uploads in the BITS documentation. This sample of
code is designed to show the difference between upload and download jobs.
Program flow
UPLOADS.cpp
builds on the concepts established in the DOWNLOADS.cpp example, it is
recommended that you review DOWNLOADS.cpp prior to reviewing this sample – it
will aid understanding of the program flow. The key difference between the two
samples is that the BG_JOB_TYPE_UPLOAD option is used when creating the job
hr = pQueueMgr->CreateJob(L"Upload",
BG_JOB_TYPE_UPLOAD, &guidJob,&pJob);
Other than
that, and the direction of data flow, the two examples are identical. The one
thing you should be aware of is that only one file can be added to an upload
job. Notifications are available on upload jobs. Please see the BITS
documentation for more information.
Key Concepts
- Basic
connection with BITS job manager and submission of BITS jobs
- Adding
a file to the job
- Specifying
the BG_JOB_TYPE_UPLOAD option.
- Submission
of upload job
Build/Configuration instructions
- Run
"VCBuild UPLOADS" in the directory
where the sources are. Or, use Visual Studio to build the job. Optionally,
the binaries are provided.
- Execute
UPLOADS.exe.
Basic Usage
- Select
a file on your local machine.
- Select
a virtual directory on a remote IIS server that has been configured for
uploads. If you need an example of how to do the configuration, see the
BITS 1.5 samples in this SDK.
- Select
a location and name of a file to upload.
- Enter
the command UPLOADS.exe <RemoteName> <LocalName> Note that the remote name will be in the
form http://REMOTEMACHINE/VIRTUALDIRECTORY/FILE
- When
the upload completes or fails, you will be notified.
System configuration
- To
be able to compile the samples, the Windows Vista SDK must be installed.
- The
sample code requires BITS version 1.5 or later versions. BITS 3.0 is
available as part of Windows Vista, or Windows Server 2008.