You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Downloading files

The session exposes the DownloadAsync method to allow you to retrieve the content of a file.

Syntax

There are two overloads:

Task<Stream> DownloadAsync(string path, Reference<RavenJObject> metadata = null);
Task<Stream> DownloadAsync(FileHeader file, Reference<RavenJObject> metadata = null);

Parameters
path string The full file path
file FileHeader The file represented by the FileHeader
metadata Reference<RavenJObject> Metadata of the downloaded file
Return Value
Task<Stream> A task that represents the asynchronous download operation. The task result is the file's content represented by a readable stream.
Exceptions
FileNotFoundException It is thrown when the requested file does not exist in the file system.

Example

Reference<RavenJObject> metadata = new Reference<RavenJObject>();

Stream content = await session.DownloadAsync("/movies/intro.avi", metadata);

Console.WriteLine("Downloaded {0} bytes", metadata.Value.Value<long>("RavenFS-Size"));