# 6. BayunS3

BayunS3 is a sample application that uses overridden methods from S3Wrapper SDK for secure storage onto AWS S3. The app itself works exactly similar to the case of an app using the original AWS S3 SDK directly. However, the wrapper SDK automatically encrypts a file before uploading it to the S3 bucket and decrypts it after downloading it, without the application having to deal with encryption keys, etc.

## AWS Credentials

To use Amazon Cognito user pools, you need an AWS account. You can create a user pool through the Amazon Cognito console. You can follow the [AWS developer guide](https://docs.aws.amazon.com/cognito/latest/developerguide/getting-started-with-cognito-user-pools.html) to create user pool.

Replace the values of UserPoold, Region and ClientId their respective values in the `config.js` file.

You are provided with an App Id and Application Secret when your app is registered with Bayun, see [Registering a new App](https://bayun.gitbook.io/bayuncoresdk-javascript-programming-guide/getting-started#2.2-register-a-new-application). In the `config.js` file, replace value of BayunAppId, BayunAppSalt, BayunAppSecret, EnableFaceRecognition, and BaseUrl.

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

```javascript
window._config = {
    cognito: {
        userPoolId: "<userPoolId>", // e.g. us-east-4_uXbttttpAb
        region: "<region>", // e.g. us-east-7
        clientId: "<clientId>", // e. g. 7s5cdrjuev1vd8531qace17nl2
    },
};

const BayunConstants = {
    BAYUN_APP_ID: "<BAYUN_APP_ID>", // provided on the admin panel
    BAYUN_APP_SALT: "<BAYUN_APP_SALT>", // provided on the admin panel
    BAYUN_APP_SECRET: "<BAYUN_APP_SECRET>", // provided on the admin panel
    ENABLE_FACE_RECOGNITION: false | true,
    BASE_URL: "<BASE_URL>", // provided on the admin panel
  };
```

{% endtab %}
{% endtabs %}

## Register and Login

You need to first signUp using Amazon Cognito User Pools . Enter your username, password, email and set your company name. Hit Register button, You will be redirected to verification page and you will receive a confirmation code on your email address. Enter the email address and confirmation code in the verification screen and complete your signup process.

After signup you can signIn to your account. Provide your username and password to signIn. You should be able to upload/download files to/from the bucket.

{% hint style="info" %}
In the BayunS3 sample app, you have to explicitly mention your bucket name, for this the bucket has to be created(with NO-CORS policy) on AWS console in advance. You can provide your own bucket name for upload/download operations.
{% endhint %}

## Where to Go From Here?

You can find the BayunS3 app on [Github](https://github.com/bayunsystems/BayunSDK/tree/master/JavaScript/TestApp/BayunS3).

For detailed step-by-step instructions on how to build and run the JavaScript application, see the [README](https://github.com/bayunsystems/BayunSDK/blob/master/JavaScript/TestApp/BayunS3/README.md) file.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bayun.gitbook.io/bayun-awss3-wrapper-javascript-programming-guide/6.-bayuns3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
