> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nami.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Object

> Retrieve an object from a bucket

<Note>
  Make sure you have READ permission on the object you want to retrieve.
</Note>

## Get Object

Retrieves objects from Nami Cloud Storage. The object data is streamed in the response body.

### Base URL

```bash theme={null}
https://${bucketname}.storage.nami.cloud
```

### Parameters

<ParamField path="objectKey" required>
  The key of the object to retrieve
</ParamField>

### Headers

<ParamField header="Range" optional>
  Downloads the specified range bytes of an object
</ParamField>

<ParamField header="If-Match" optional>
  Return the object only if its entity tag (ETag) is the same as specified
</ParamField>

<ParamField header="If-Modified-Since" optional>
  Return the object only if it has been modified since the specified time
</ParamField>

### Request Examples

<RequestExample>
  ```bash Bash theme={null}
  curl "https://mybucket.storage.nami.cloud/example.jpg" \
    -H "Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20231028/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-date, Signature=fe5f80f77d5fa3beca038a248ff027d0445342fe2855ddc963176630326f1024" \
    --output example.jpg
  ```

  ```python Python theme={null}
  import boto3

  s3_client = boto3.client('s3',
      endpoint_url='https://storage.nami.cloud',
      aws_access_key_id='YOUR_ACCESS_KEY',
      aws_secret_access_key='YOUR_SECRET_KEY'
  )

  s3_client.download_file(
      Bucket='mybucket',
      Key='example.jpg',
      Filename='downloaded_example.jpg'
  )
  ```

  ```javascript Node.js theme={null}
  import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
  import { createWriteStream } from "fs";

  const client = new S3Client({
    endpoint: "https://storage.nami.cloud",
    credentials: {
      accessKeyId: "YOUR_ACCESS_KEY",
      secretAccessKey: "YOUR_SECRET_KEY",
    },
  });

  async function downloadFile() {
    const command = new GetObjectCommand({
      Bucket: "mybucket",
      Key: "example.jpg",
    });

    try {
      const response = await client.send(command);
      const writeStream = createWriteStream('downloaded_example.jpg');
      response.Body.pipe(writeStream);
    } catch (err) {
      console.error("Error:", err);
    }
  }

  downloadFile();
  ```

  ```go Golang theme={null}
  package main

  import (
      "github.com/aws/aws-sdk-go/aws"
      "github.com/aws/aws-sdk-go/aws/credentials"
      "github.com/aws/aws-sdk-go/aws/session"
      "github.com/aws/aws-sdk-go/service/s3"
      "os"
  )

  func main() {
      sess := session.Must(session.NewSession(&aws.Config{
          Endpoint:    aws.String("https://storage.nami.cloud"),
          Region:      aws.String("us-east-1"),
          Credentials: credentials.NewStaticCredentials("YOUR_ACCESS_KEY", "YOUR_SECRET_KEY", ""),
      }))

      s3Client := s3.New(sess)

      file, err := os.Create("downloaded_example.jpg")
      if err != nil {
          panic(err)
      }
      defer file.Close()

      result, err := s3Client.GetObject(&s3.GetObjectInput{
          Bucket: aws.String("mybucket"),
          Key:    aws.String("example.jpg"),
      })
      if err != nil {
          panic(err)
      }
      defer result.Body.Close()

      _, err = file.ReadFrom(result.Body)
      if err != nil {
          panic(err)
      }
  }
  ```

  ```rust Rust theme={null}
  use aws_sdk_s3::{Client, Config};
  use aws_config::credentials::StaticCredentialsProvider;
  use aws_types::region::Region;
  use tokio::fs::File;
  use tokio::io::AsyncWriteExt;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let credentials = StaticCredentialsProvider::new(
          "YOUR_ACCESS_KEY".to_string(),
          "YOUR_SECRET_KEY".to_string(),
          None,
      );

      let config = Config::builder()
          .endpoint_url("https://storage.nami.cloud")
          .region(Region::new("us-east-1"))
          .credentials_provider(credentials)
          .build();

      let client = Client::from_conf(config);

      let response = client
          .get_object()
          .bucket("mybucket")
          .key("example.jpg")
          .send()
          .await?;

      let mut file = File::create("downloaded_example.jpg").await?;
      let bytes = response.body.collect().await?.into_bytes();
      file.write_all(&bytes).await?;

      println!("Download successful!");
      Ok(())
  }
  ```
</RequestExample>

### Response Example

```json theme={null}
HTTP/1.1 200 OK
x-amz-id-2: ef8yU9AS1ed4OpIszj7UDNEHGran
x-amz-request-id: 318BC8BC143432E5
Date: Wed, 28 Oct 2023 22:32:00 GMT
Last-Modified: Wed, 28 Oct 2023 19:27:20 GMT
ETag: "b9875f283e5571ae9ac762fba126cf8d"
Content-Length: 434234
Content-Type: image/jpeg
Server: Nami Cloud

[Object Data]
```


## OpenAPI

````yaml GET /{objectKey}
openapi: 3.0.1
info:
  title: Nami Cloud Storage API
  description: S3 compatible storage service API documentation
  version: 1.0.0
servers:
  - url: https://{bucketName}.storage.nami.cloud
    variables:
      bucketName:
        default: mybucket
        description: The name of the bucket
security:
  - awsV4: []
paths:
  /{objectKey}:
    get:
      tags:
        - Object Operations
      summary: Get Object
      description: Retrieves objects from a bucket
      parameters:
        - name: objectKey
          in: path
          required: true
          description: Key of the object
          schema:
            type: string
      responses:
        '200':
          description: Object retrieved successfully
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
components:
  securitySchemes:
    awsV4:
      type: apiKey
      name: Authorization
      in: header
      description: AWS Signature Version 4

````