# Upload file

#### Syntax

#### &#x20;                                               eueno.upload(input,`[opts],metadata`)

#### Example

```
const Eueno = require('@eueno/lib-node');
const fs = require('fs');

async function example() {
  const eueno = new Eueno({
    endpoint: 'https://v2-developers.eueno.io',
  });
  const file = await fs.readFileSync('1.png');

  const data = await eueno.upload(
    file,
    {
      projectKey: 'project_key',
      key: {
        walletPublicKey: 'public_key_of_user_if_method_encrypt',
        fileEncryptionKey: 'key_encrypt_file'
      },
    },
    {
      projectId: 129,
      filename: '1.png',
      contentLength: 12313,
      contentType: 'image/png',
      method: 'ENCRYPT',
      keepPath: false,
    },
  );
}


example();
```

## Parameters

<table><thead><tr><th width="135">Name</th><th width="107">Type</th><th width="119">Required</th><th>Description</th></tr></thead><tbody><tr><td>Input</td><td>Buffer</td><td>Yes</td><td>Buffer file data</td></tr><tr><td>opts</td><td>Object</td><td>Yes</td><td>Initialization parameter</td></tr><tr><td>metadata</td><td>Object</td><td>Yes</td><td>Info a file and project</td></tr></tbody></table>

## Properties <a href="#properties" id="properties"></a>

**opts**

<table><thead><tr><th width="135">Name</th><th width="107">Type</th><th width="119">Required</th><th>Description</th></tr></thead><tbody><tr><td>projectKey</td><td>String</td><td>Yes</td><td>project key to authenticate client and eueno server</td></tr><tr><td>key</td><td>Object</td><td>No</td><td>The keys in encrypting the file if the storage method is encryption.</td></tr></tbody></table>

**key**

<table><thead><tr><th width="191">Name</th><th width="107">Type</th><th width="119">Required</th><th>Description</th></tr></thead><tbody><tr><td>walletPublicKey</td><td>String</td><td>Yes</td><td>public key of the user used to encrypt the file encryption key <code>fileEncryptionKey</code></td></tr><tr><td>fileEncryptionKey</td><td>String</td><td>No</td><td>Symmetric key used to encrypt files</td></tr></tbody></table>

**metadata**&#x20;

<table><thead><tr><th width="170">Name</th><th width="107">Type</th><th width="119">Required</th><th>Description</th></tr></thead><tbody><tr><td>projectId</td><td>Int</td><td>Yes</td><td>Id project eueno</td></tr><tr><td>path</td><td>String </td><td>No</td><td>Path storage on eueno</td></tr><tr><td>filename</td><td>String</td><td>Yes</td><td>Name of file</td></tr><tr><td>contentLength</td><td>Int</td><td>Yes</td><td>Size of file</td></tr><tr><td>contentType</td><td>String</td><td>Yes</td><td>Type of file eg: image/png</td></tr><tr><td>method</td><td>String</td><td>Yes</td><td>Encrypted or Unencrypted Storage Method <code>ENCRYPT</code> or UNENCRYPTED</td></tr><tr><td>keepPath</td><td>Boolean</td><td>No</td><td>To avoid duplicate names on eueno's mfs system, we will add a datetime field to the name of the file.</td></tr></tbody></table>
