This package has been deprecated

Author message:

This component is deprecated

@advanced-rest-client/multipart-payload-transformer
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

Published on NPM

Build Status

Published on webcomponents.org

multipart-payload-transformer

An element to transform FormData object into Multipart message and ArrayBuffer.

Usage

Installation

npm install --save @advanced-rest-client/multipart-payload-transformer

In a LitElement

import { LitElement, html } from 'lit-element';
import '@advanced-rest-client/code-mirror/code-mirror.js';

class SampleElement extends PolymerElement {
  render() {
    const formData = new FormData();
    formData.add('filed', new Blob(['test'], { type: 'text/plain' }));
    return html`
    <multipart-payload-transformer .formData="${formData}"></multipart-payload-transformer>
    `;
  }

  async run() {
    const message = await this.shadowRoot.querySelector('multipart-payload-transformer').generateMessage();
    console.log(message);
  }
}
customElements.define('sample-element', SampleElement);

In a Polymer 3 element

import {PolymerElement, html} from '@polymer/polymer';
import '@advanced-rest-client/multipart-payload-transformer/multipart-payload-transformer.js';

class SampleElement extends PolymerElement {
  static get template() {
    return html`
    <multipart-payload-transformer formdata="[[formData]]"></multipart-payload-transformer>
    `;
  }

  static get properties() {
    return {
      formData: Object
    }
  }

  constructor() {
    super();
    const fd = new FormData();
    fd.add('test', 'value');
    this.formData = fd;
  }
}
customElements.define('sample-element', SampleElement);

Development

git clone https://github.com/advanced-rest-client/multipart-payload-transformer
cd multipart-payload-transformer
npm install

Running the demo locally

npm start

Running the tests

npm test

API components

This components is a part of API components ecosystem

Package Sidebar

Install

npm i @advanced-rest-client/multipart-payload-transformer

Weekly Downloads

308

Version

3.0.0

License

Apache-2.0

Unpacked Size

41.4 kB

Total Files

6

Last publish

Collaborators

  • carowright
  • jarrodek
  • twoplustwoone
  • lbauret