# File Pre-Import

Pre-const configuration = {
      baseUrl: 'https://123.ngrok.io',
      clientId: 'clientId',
      clientSecret: 'clientSecret',
      name: 'Sample App',
      identifier: 'sample-app',
      description: 'Sample App description',
      dbFolder: import.meta.dirname,
      imagePath: import.meta.dirname + '/logo.png',
      filePreImport: [
        {
          filesFolder: `${import.meta.dirname}/db`,
          signaturePatterns: {
            fileName: "^.+\\..+$",
            fileContent: ".*"
          },
          fileProcess: async ({ request, content, client, context, projectId }) => {
            const fileName = 'newFileName.txt';
            const contentFile = Buffer.from(
              content.toString().replace('<text-to-replace>','<content>')
            );
            return { contentFile, fileName };
          }
        }
      ]
    };

    crowdinModule.createApp(configuration);
    ```
  ```ts ins="filePreImport" title="index.ts"
    const configuration: ClientConfig = {
      baseUrl: 'https://123.ngrok.io',
      clientId: 'clientId',
      clientSecret: 'clientSecret',
      name: 'Sample App',
      identifier: 'sample-app',
      description: 'Sample App description',
      dbFolder: import.meta.dirname,
      imagePath: import.meta.dirname + '/logo.png',
      filePreImport: [
        {
          filesFolder: `${import.meta.dirname}/db`,
          signaturePatterns: {
            fileName: "^.+\\..+$",
            fileContent: ".*"
          },
          fileProcess: async ({ request, content, client, context, projectId }) => {
            const fileName = 'newFileName.txt';
            const contentFile = Buffer.from(
              content!.toString().replace('<text-to-replace>','<content>')
            );
            return { contentFile, fileName };
          }
        }
      ]
    };

    crowdinModule.createApp(configuration);
    ```
  ## Configuration

| Parameter<div class="w-40"/> | Description                                                                                                                           |
|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| `filesFolder`                | Folder where large files are temporarily stored.                                                                                      |
| `signaturePatterns`          | Contains `fileName` and/or `fileContent` regular expressions used to detect file type when uploading a new source file via UI or API. |
| `processAssets`              | Set to `true` to enable processing of assets (e.g., images, videos) within the application. By default, assets are not processed.       |

### `fileProcess` Function

This function is called for each file that is imported to Crowdin.

##### Parameters

- `request` - Request object.
- `content` - File content.
- `client` - Crowdin API client.
- `context` - [Context object](/app-project-module/reference/context/).
- `projectId` - Crowdin project ID.

##### Return Value

The function should return the following object:

```yml
{
  contentFile: Buffer,
  fileName?: string,
  notModified?: boolean,
  error?: string
}
```

**Description:**

- `contentFile` - should contain the modified file content.
- `fileName` - optional, should contain the new file name if the file processor changes the file name.
- `notModified` - optional, should be set to `true` if the file processor does not make any changes to the file.
- `error` - optional, should contain an error message if the file processor encounters an error.