🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

atmedia-image-uploader

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atmedia-image-uploader

React image uploader with drag and drop support

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

ImageUploader

Props

  • handleImages: Function to handle successful uploads. Should accept a single argument, the array of uploaded images.

  • uploadImage: Function to upload a single file. Should accept a single argument of a File object. Should return a promise that, when resolved, delivers a response in the shape of:

    { image: { id: 1, ... } }
    

    When rejected, it should return a response object in the shape of:

    { message: 'something went wrong' }
    

Usage

Download on npm: npm install atmedia-image-uploader

Sample usage:

const ImageUploader = require('atmedia-image-uploader');

function handleImages(images = []) {
  this.setState({ images });
}

function uploadImage(imageFile) {
  const url = '//upload.apartmenttherapy.com/upload';
  const opts = {
    method: 'POST',
    body: new FormData()
  };
  return new Promise((resolve, reject) => {
    fetch(url, opts)
    .then(response => response.json())
    .then(resolve)
    .catch(reject);
  });
}

ReactDOM.render(
  <ImageUploader
    handleImages={handleImages}
    uploadImage={uploadImage}
  />,
  document.querySelector('image-uploader-container');
);

FAQs

Package last updated on 12 Jul 2017

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