# File Post-Export

The post-export app allows you to modify your files after exporting them from Crowdin. With this type of app, you can apply automated modifications to selected files.

[File Post-Export Processing Module](https://support.crowdin.com/developer/crowdin-apps-module-file-post-export-processing/)

## Sample

```js ins="filePostExport" title="index.js"
    import crowdinModule from '@crowdin/app-project-module';

    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',
      filePostExport: [
        {
          filesFolder: `${import.meta.dirname}/db`,
          signaturePatterns: {
            fileName: "^.+\\..+$",
            fileContent: ".*"
          },
          fileProcess: async ({ request, content, client, context, projectId }) => {
            const contentFile = Buffer.from(
              content.toString().replace('<text-to-replace>','<content>')
            );
            return { contentFile };
          }
        }
      ]
    };

    crowdinModule.createApp(configuration);
    ```
  ```ts ins="filePostExport" title="index.ts"
    import crowdinModule from '@crowdin/app-project-module';
    import type { ClientConfig } from '@crowdin/app-project-module';

    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',
      filePostExport: [
        {
          filesFolder: `${import.meta.dirname}/db`,
          signaturePatterns: {
            fileName: "^.+\\..+$",
            fileContent: ".*"
          },
          fileProcess: async ({ request, content, client, context, projectId }) => {
            const contentFile = Buffer.from(
              content!.toString().replace('<text-to-replace>','<content>')
            );
            return { contentFile };
          }
        }
      ]
    };

    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 exported from 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,
  notModified?: boolean,
  error?: string
}
```

**Description:**

- `contentFile` - should contain the modified file content.
- `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.