Skip to content
Back to skills

Gcs Rust Download Object Api

ASecurity

Fix "DownloadObjectRequest not found" error in google-cloud-storage Rust crate. Use when: (1) Trying to download objects from GCS using the Rust SDK, (2) Looking for a download request type in http::objects::download module, (3) Compile error about missing type. The download_object method uses GetObjectRequest from the get module, not a separate DownloadObjectRequest type.

  • 265 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 27, 2026
developmentrustgoapi

Works with

  • claude code
  • cli
  • api

Security analysis

A100/100

Scanned May 27, 2026

npx -y skills add divinevideo/divine-mobile --skill gcs-rust-download-object-api --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Gcs Rust Download Object Api?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Gcs Rust Download Object Api
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/divinevideo-gcs-rust-download-object-api/badge)](https://www.skillsdirectory.com/skills/divinevideo-gcs-rust-download-object-api)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: gcs-rust-download-object-api
description: |
  Fix "DownloadObjectRequest not found" error in google-cloud-storage Rust crate. Use when:
  (1) Trying to download objects from GCS using the Rust SDK, (2) Looking for a download
  request type in http::objects::download module, (3) Compile error about missing type.
  The download_object method uses GetObjectRequest from the get module, not a separate
  DownloadObjectRequest type.
author: Claude Code
version: 1.0.0
date: 2026-01-27
---

# GCS Rust SDK Download Object API

## Problem
When using the `google-cloud-storage` Rust crate to download objects, developers often
look for a `DownloadObjectRequest` type in the `download` module, expecting it to mirror
the upload pattern. This type doesn't exist, causing confusing compile errors.

## Context / Trigger Conditions
- Using `google-cloud-storage` crate in Rust
- Trying to call `client.download_object()`
- Error: `unresolved import google_cloud_storage::http::objects::download::DownloadObjectRequest`
- Looking in `http::objects::download` module for request types

## Solution

The `download_object` method uses `GetObjectRequest` from the `get` module, combined with
`Range` from the `download` module:

```rust
use google_cloud_storage::http::objects::{
    download::Range as DownloadRange,
    get::GetObjectRequest,
};

// Download full object
let data = client.download_object(
    &GetObjectRequest {
        bucket: "my-bucket".to_string(),
        object: "path/to/object".to_string(),
        ..Default::default()
    },
    &DownloadRange::default(),
).await?;

// Download partial object (bytes 0-1023)
let partial = client.download_object(
    &GetObjectRequest {
        bucket: "my-bucket".to_string(),
        object: "path/to/object".to_string(),
        ..Default::default()
    },
    &DownloadRange::Bounded(0, 1023),
).await?;
```

## Verification
Code compiles and `download_object` returns `Vec<u8>` with the object contents.

## Example

```rust
use google_cloud_storage::{
    client::{Client as GcsClient, ClientConfig},
    http::objects::{
        download::Range as DownloadRange,
        get::GetObjectRequest,
        upload::{Media, UploadObjectRequest, UploadType},
    },
};

async fn download_from_gcs(client: &GcsClient, bucket: &str, key: &str) -> Result<Vec<u8>> {
    let data = client.download_object(
        &GetObjectRequest {
            bucket: bucket.to_string(),
            object: key.to_string(),
            ..Default::default()
        },
        &DownloadRange::default(),
    ).await?;

    Ok(data)
}
```

## Notes
- The `Range` type is aliased as `DownloadRange` to avoid conflicts with std::ops::Range
- `DownloadRange::default()` downloads the entire object
- For checking if an object exists without downloading, use `get_object` with `GetObjectRequest`
- The `Media.content_type` field is `Cow<'static, str>`, use `.into()` for string conversion

## References
- [google-cloud-storage crate docs](https://docs.rs/google-cloud-storage)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.