ocf-converter-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

ocf-converter-sdk for TypeScript

SDK for onlineconvertfree.com file conversion API.

Installation & Usage

Requirements

Node.js 16.15.1.

Install

npm install ocf-converter-sdk

Getting Started

Please follow the installation procedure and then start from the following:

import * as fs from 'fs';
import * as https from 'https';
import { OcfClient } from 'ocf-converter-sdk';

const apiKey = 'myApiKey';

const client = new OcfClient(apiKey);

const filePath = '/path/to/file/to/convert.png';
const extensionToConvertTo = 'pdf';

const task = await client.uploadFile(filePath, extensionToConvertTo);

const result = await task.waitForConversion();

if (result.isSuccess()) {
    const resultUrl = result.getResultingFileUrl() as string;

    https.get(resultUrl, (response => {
        const path = `${__dirname}/result.${extensionToConvertTo}`;
        const filePath = fs.createWriteStream(path);
        response.pipe(filePath);
        filePath.on('finish', async () => {
            filePath.close();

            await result.deleteFile();
        });
    }));
}

License

SDK is made available under the MIT License (MIT). Please see License File for more information.

Contribution

OpenAPI Typescript Codegen is used for the client generation.

Requirements

OpenAPI Typescript Codegen is required for the client generation.

Client generation

To regenerate the client do the following:

  • run generation command:
npm run api-codegen
  • reformat the generated code with your IDE.

Package Sidebar

Install

npm i ocf-converter-sdk

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

168 kB

Total Files

78

Last publish

Collaborators

  • webpractik-main