# AWS S3

### Imports

{% tabs %}
{% tab title="Service" %}

```typescript
import { AwsS3Service } from 'niro-health';
```

{% endtab %}

{% tab title="Module" %}

```typescript
import { AwsS3Module } from 'niro-health';
```

{% endtab %}

{% tab title="Interface" %}

```typescript
import type { IAwsS3Service } from 'niro-health';
```

{% endtab %}
{% endtabs %}

### Method of Use

To use this module, you need to inject it into the desired service.

{% code overflow="wrap" %}

```typescript
import { Module } from '@nestjs/common';
import {
  AwsS3Service,
  AwsCoreService,
  AwsConfigurationService,
  AwsStsService,
  ConfigurationService,
  ValidatorRegexpService,
  StringExService,
} from 'niro-health';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: 'IAwsS3Service',
      useClass: AwsS3Service,
    },
    {
      provide: 'IAwsCoreService',
      useClass: AwsCoreService,
    },
    {
      provide: 'IAwsConfigurationService',
      useClass: AwsConfigurationService,
    },
    {
      provide: 'IAwsStsService',
      useClass: AwsStsService,
    },
    {
      provide: 'IConfigurationService',
      useClass: ConfigurationService,
    },
    {
      provide: 'IValidatorRegexpService',
      useClass: ValidatorRegexpService,
    },
    {
      provide: 'IStringExService',
      useClass: StringExService,
    },
  ],
})
export class AppModule {}
```

{% endcode %}

Injecting the module into our service.

```typescript
import { Inject, Injectable } from '@nestjs/common';
import type { IAwsS3Service } from 'niro-health';

@Injectable()
export class AppService {
  constructor(
    @Inject('IAwsS3Service')
    private readonly awsS3Service: IAwsS3Service,
  ) {}

  async getFile() {
    return await this.awsS3Service.get('my-photo', 'png', 1, 'my-bucket');
  }
}
```

### With dependencies

You will need to inject the following interfaces.

| Interface                  | Service                                                                                                   |
| -------------------------- | --------------------------------------------------------------------------------------------------------- |
| `IAwsCoreService`          | [Link to Service documentation](https://guilhermesantos.gitbook.io/niro-health/modules/aws-core)          |
| `IConfigurationService`    | [Link to Service documentation](https://guilhermesantos.gitbook.io/niro-health/modules/configuration)     |
| `IValidatorRegexpService`  | [Link to Service documentation](https://guilhermesantos.gitbook.io/niro-health/modules/validator-regexp)  |
| `IStringExService`         | [Link to Service documentation](https://guilhermesantos.gitbook.io/niro-health/modules/stringex)          |
| `IAwsConfigurationService` | [Link to Service documentation](https://guilhermesantos.gitbook.io/niro-health/modules/aws-configuration) |
| `IAwsStsService`           | [Link to Service documentation](https://guilhermesantos.gitbook.io/niro-health/modules/aws-sts)           |

### Methods

<table><thead><tr><th>Method</th><th width="104.33333333333331" align="center">Scope</th><th>Description</th></tr></thead><tbody><tr><td><code>client</code></td><td align="center"><code>public</code></td><td><code>Get the AWS S3 client.</code></td></tr><tr><td><code>setRole3rdParty</code></td><td align="center"><code>public</code></td><td><code>Set the role 3rd party.</code></td></tr><tr><td><code>upload</code></td><td align="center"><code>public</code></td><td><code>Upload a file to S3.</code></td></tr><tr><td><code>get</code></td><td align="center"><code>public</code></td><td><code>Get a file from S3.</code></td></tr><tr><td><code>delete</code></td><td align="center"><code>public</code></td><td><code>Delete a file from S3.</code></td></tr></tbody></table>
