> ## 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.

# 객체 삭제

> 최신 글로벌 합의 프로토콜 및 분산 저장소로 클라우드 서비스를 혁신하다

<Note>
  버킷에 대한 쓰기 권한이 있는지 확인하세요.
</Note>

## 객체 삭제

버킷에서 객체를 제거합니다. 이 작업은 멱등적입니다 - 동일한 객체에 대해 여러 삭제 요청을 보내도 추가적인 효과는 없습니다.

### 기본 URL

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

### 매개변수

<ParamField path="objectKey" required>
  삭제할 객체의 키
</ParamField>

### 헤더

<ParamField header="x-amz-mfa" optional>
  MFA 삭제가 활성화된 경우 MFA 인증 코드
</ParamField>

<ParamField header="x-amz-version-id" optional>
  삭제할 객체의 버전 ID (버전 관리 버킷의 경우)
</ParamField>

### 요청 예제

<RequestExample>
  ```bash Bash theme={null}
  curl -X DELETE "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"
  ```

  ```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.delete_object(
      Bucket='mybucket',
      Key='example.jpg'
  )
  ```

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

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

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

    try {
      const response = await client.send(command);
      console.log("삭제 성공:", response);
    } catch (err) {
      console.error("오류:", err);
    }
  }

  deleteFile();
  ```

  ```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"
  )

  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)

      _, err := s3Client.DeleteObject(&s3.DeleteObjectInput{
          Bucket: aws.String("mybucket"),
          Key:    aws.String("example.jpg"),
      })
      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;

  #[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);

      client
          .delete_object()
          .bucket("mybucket")
          .key("example.jpg")
          .send()
          .await?;

      println!("삭제 성공!");
      Ok(())
  }
  ```
</RequestExample>

### 응답 예제

```json theme={null}
HTTP/1.1 204 No Content
x-amz-id-2: JuKZqmXuiwFeDQxhD7M8KtsKobSzWA1QEjLbTMTagkKdBX2z7Il/jGhDeJ3j6s80
x-amz-request-id: 32FE2CEB32F5EE25
Date: Wed, 28 Oct 2023 22:32:00 GMT
Server: Nami Cloud
```


## OpenAPI

````yaml DELETE /
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:
  /:
    delete:
      tags:
        - Bucket Operations
      summary: Delete Bucket
      description: Deletes an empty bucket
      responses:
        '204':
          description: Bucket deleted successfully
        '404':
          description: Bucket not found
          content:
            application/xml:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      properties:
        Code:
          type: string
        Message:
          type: string
        RequestId:
          type: string
  securitySchemes:
    awsV4:
      type: apiKey
      name: Authorization
      in: header
      description: AWS Signature Version 4

````