# Interface: ExportConfig

[Mobile Web Capture API Reference](../index.md) / ExportConfig

# Interface: ExportConfig

Handlers that connect Mobile Web Capture's export features to your own server.

## Remarks

Which features appear in the UI depends on which handlers are defined:

- [ExportConfig.uploadToServer](#uploadtoserver) alone adds an **Upload** button to the `DocumentView` and `PageView` (and the `LibraryView`, when enabled).
- Defining `uploadToServer`, [ExportConfig.downloadFromServer](#downloadfromserver), and [ExportConfig.deleteFromServer](#deletefromserver) together additionally enables **Upload History** in the `LibraryView`.

## See

[Enable file upload](https://www.dynamsoft.com/mobile-document-scanner/docs/web/code-gallery/mobile-web-capture/customization-guide.html#enable-file-upload)

## Example

```javascript
const uploadToServer = async (fileName, blob) => {
    const formData = new FormData();
    formData.append("uploadFile", blob, fileName);
    const response = await fetch(`${window.location.origin}/upload`, {
        method: "POST",
        body: formData,
    });
    // Returning { status: "success" } is required to trigger onUploadSuccess.
    return { status: response.status === 200 ? "success" : "failed" };
};

const mobileWebCapture = new Dynamsoft.MobileWebCapture({
    license: "YOUR_LICENSE_KEY_HERE",
    exportConfig: {
        uploadToServer,
        onUploadSuccess: async (fileName) => {
            console.log(`${fileName} uploaded successfully!`);
            return true; // Close the Mobile Web Capture instance
        },
    },
});
```

## Properties

### deleteFromServer?

> `optional` **deleteFromServer?**: (`doc`) => `Promise`\<`void`\>

Deletes a previously uploaded document from your server.

#### Parameters

##### doc

[`UploadedDocument`](../type-aliases/UploadedDocument.md)

The document the user selected, as returned by `uploadToServer`.

#### Returns

`Promise`\<`void`\>

#### Remarks

Called when the user deletes a document from the upload history. Required, together with [ExportConfig.uploadToServer](#uploadtoserver) and [ExportConfig.downloadFromServer](#downloadfromserver), to enable **Upload History**.

***

### downloadFromServer?

> `optional` **downloadFromServer?**: (`doc`) => `Promise`\<`void`\>

Downloads a previously uploaded document from your server.

#### Parameters

##### doc

[`UploadedDocument`](../type-aliases/UploadedDocument.md)

The document the user selected, as returned by `uploadToServer`.

#### Returns

`Promise`\<`void`\>

#### Remarks

Called when the user picks a document in the upload history. Required, together with [ExportConfig.uploadToServer](#uploadtoserver) and [ExportConfig.deleteFromServer](#deletefromserver), to enable **Upload History**.

***

### onUploadSuccess?

> `optional` **onUploadSuccess?**: (`fileName`, `fileType`, `view`, `blob`) => `Promise`\<`boolean`\>

Runs after an upload reports success.

#### Parameters

##### fileName

`string`

Name of the uploaded file.

##### fileType

`string`

MIME type of the uploaded file.

##### view

[`EnumMWCViews`](../enumerations/EnumMWCViews.md)

The View the upload was started from.

##### blob

[`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)

The uploaded file contents.

#### Returns

`Promise`\<`boolean`\>

`true` to close the Mobile Web Capture instance after the upload, `false` to leave it open.

#### Remarks

Only called when [ExportConfig.uploadToServer](#uploadtoserver) resolved with `status: "success"`.

***

### uploadToServer?

> `optional` **uploadToServer?**: (`fileName`, `blob`) => `Promise`\<`void` \| [`UploadedDocument`](../type-aliases/UploadedDocument.md)\>

Uploads a document or page to your server.

#### Parameters

##### fileName

`string`

Name of the file being uploaded.

##### blob

[`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)

The file contents — a multi-page PDF for a document, a PNG for a single page.

#### Returns

`Promise`\<`void` \| [`UploadedDocument`](../type-aliases/UploadedDocument.md)\>

#### Remarks

Defining this handler is what puts the **Upload** button in the UI. Resolve with an [UploadedDocument](../type-aliases/UploadedDocument.md) whose `status` is `"success"` to trigger [ExportConfig.onUploadSuccess](#onuploadsuccess) and to list the document in the upload history; resolving with `void` uploads without either.
