Socket
Socket
Sign inDemoInstall

@cincel.digital/doc-convert-request

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cincel.digital/doc-convert-request

HTTP client for @cincel.digital/doc-convert-plugin package


Version published
Maintainers
2
Created
Source

@cincel.digital/doc-convert-request

@cincel.digital/doc-convert-request is a package designed to connect with @cincel.digital/doc-convert-plugin, a Hapi plugin that converts documents to PDF. This package provides HTTP-related functionality for document conversion.

Installation

yarn add @cincel.digital/doc-convert-request

# or

npm i @cincel.digital/doc-convert-request

Usage

To use this package, you need to import the function http from @cincel.digital/doc-convert-request.

Converting a File to PDF

The http function allows you to convert a file to PDF by sending an HTTP POST request to the specified URL. The function takes two parameters: the URL and the file to be converted.

import { request } from "@cincel.digital/doc-convert-request"

const upload =
const filepicker = document.getElementById("filepicker") as HTMLInputElement

filepicker.addEventListener("change", (event) => {
  const file = event.target.files?.[0]
  if (!file) return
  request("http://example.com/convert", file)
    .then((pdfFile) => {
      return pdfFile
    })
    .catch((err) => {
      console.error(err)
    })
})

Downloading a Raw URL

The downloadRawURL function allows you to generate a download URL for a PDF file. It takes a File object as input and returns a URL that can be used for downloading the file.

import { request, downloadRawURL } from "@cincel.digital/doc-convert-request"

const filepicker = document.getElementById("filepicker") as HTMLInputElement

filepicker.addEventListener("change", (event) => {
  const file = event.target.files?.[0]
  if (!file) return
  request("http://example.com/convert", file)
    .then((pdfFile) => {
      const downloadRawURL = downloadRawURL(pdfFile)
      window.open(downloadRawURL, "_blank")

      return pdfFile
    })
    .catch((err) => {
      console.error(err)
    })
})

Please note that the @cincel.digital/doc-convert-plugin plugin is required for the proper functioning of this package. Make sure to install and configure the plugin according to its documentation before using @cincel.digital/doc-convert-request.

FAQs

Package last updated on 05 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc