Manage Applications

    Download a file

    get
    https://api.box.com/2.0
    /files/:file_id/content

    Returns the contents of a file in binary format.

    Request

    application/json

    Path Parameters

    stringin pathrequired
    12345

    The unique identifier that represent a file.

    The ID for any file can be determined by visiting a file in the web application and copying the ID from the URL. For example, for the url https://*.app.box.com/files/123 the file_id is 123.

    Query Parameters

    stringin queryoptional
    4

    The file version to download

    Request Headers

    stringin headeroptional
    shared_link=[link]

    The URL and password for a file that has been shared using a shared link, as this file would otherwise not be accessible to the user.

    Use the format shared_link=SHARED_LINK_URL or if a password was set use shared_link=[link]&shared_link_password=[password]

    stringin headeroptional
    0-1024

    The byte range of the content to download.

    The format {start_byte}-{end_byte} can be used to specify what section of the file to download.

    Response

    none

    If the file is not ready to be downloaded yet Retry-After header will be returned indicating the time in seconds after which the file will be available for the client to download.

    This response can occur when the file was uploaded immediately before the download request.

    none

    If the file is available to be downloaded the response will include a Location header for the file on dl.boxcloud.com.

    The dl.boxcloud.com URL is not persistent and clients will need to follow the redirect in order to actually download the file.

    You can now try out some of our APIs live, right here in the documentation.
    Log In

    Request Example

    cURL
    curl -X GET https://api.box.com/2.0/files/12345/content \
         -H "Authorization: Bearer <ACCESS_TOKEN>"
    .NET
    Stream fileContents = await client.FilesManager.DownloadStreamAsync(id: "11111");
    Java
    BoxFile file = new BoxFile(api, "id");
    List<BoxFileVersion> versions = file.getVersions();
    BoxFileVersion firstVersion = versions.get(0);
    
    FileOutputStream stream = new FileOutputStream(firstVersion.getName());
    firstVersion.download(stream);
    stream.close();
    Python
    file_id = '11111'
    
    # Download the entire file into memory
    file_content = client.file(file_id).content()
    
    # Download a specific file verison
    file_version = client.file_version('12345')
    version_content = client.file(file_id).content(file_version=file_version)
    
    # Download the first 100 bytes of the file
    beginning_of_file_content = client.file(file_id).content(byte_range=(0,99))
    Node
    var fs = require('fs');
    client.files.getReadStream('12345', null, function(error, stream) {
    
    	if (error) {
    		// handle error
    	}
    
    	// write the file to disk
    	var output = fs.createWriteStream('/path/to/file');
    	stream.pipe(output);
    });