npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

imagekit-uppy-plugin

v2.0.1-alpha.2

Published

A plugin for Uppy, which allows you to upload files directly to ImageKit.io media library.

Downloads

54

Readme

ImageKit.io plugin for Uppy upload widget

npm version License: MIT Twitter Follow

A plugin for Uppy, which allows you to upload files directly to ImageKit.io media library.

Getting started

You can see a hosted demo of using this plugin in a real project here or fork sample project codesandbox.io.

  • Sample project using this plugin with Dropbox, Drive and Facebook upload options.
  • A step by step walkthrough of sample project is available at https://docs.imagekit.io/sample-projects/upload-widget/uppy-upload-widget/.
  • ImageKit.io Upload API documentation.

Minimal setup

The plugin is published on npm. First, you need to install it using npm or yarn.

Using yarn

yarn add imagekit-uppy-plugin

Using npm

npm install imagekit-uppy-plugin --save

Then include it in your application with mandatory parameters i.e. id, authenticationEndpoint and publicKey.

import Uppy from '@uppy/core'
import '@uppy/core/dist/style.css'
import '@uppy/dashboard/dist/style.css'
import Dashboard from '@uppy/dashboard'
import ImageKitUppyPlugin from "imagekit-uppy-plugin"

const uppy = Uppy({ debug: true, autoProceed: false })
    .use(Dashboard, {
        inline: true,
        trigger: '#uppyDashboard', // your element
    })
    .use(ImageKitUppyPlugin, {
        id: 'ImageKit',
        authenticationEndpoint: `http://www.yourserver.com/auth`,
        publicKey: "your_public_key"
    })

The plugin makes an HTTP GET request to authenticationEndpoint and expects a JSON response with three fields i.e. signature, token and expire. In addition, the plugin adds a query parameter t with a random value to ensure that the request URL is unique and the response is not cached in Safari iOS. Your backend can ignore this query parameter.

Learn how to implement authenticationEndpoint on your server using ImageKit.io server-side SDKs.

Modify file name, destination path or add tags during upload

By default, this plugin will send all properties of file meta object as string values with the upload requests. You can control which properties to send as part of the upload request using metaFields field while initializing the ImageKit Uppy plugin. Ideally, you should only allow the supported upload request parameters to avoid any surprises.

const uppy = Uppy({ debug: true, autoProceed: false })
    .use(Dashboard, {
        inline: true,
        trigger: '#uppyDashboard', // your element
        metaFields : [
            {
                id: 'name', name: 'File name', placeholder: 'Enter the file name'
            },
            {
                id: 'folder', name: 'Folder path', placeholder: 'The destination path e.g. /website-assets'
            }
        ]
    })
    .use(ImageKitUppyPlugin, {
        id: 'ImageKit',
        authenticationEndpoint: `http://www.yourserver.com/auth`,
        publicKey: "your_public_key"
        metaFields: [
            "useUniqueFileName",
            "tags",
            "folder",
            "isPrivateFile",
            "customCoordinates",
            "responseFields"
        ]
    })

Enable batch upload

You can use the limit parameter to enable batch processing and set the batch size for upload. By default, all upload requests are sent simultaneously.

In the following example, the selected files would be uploaded in batches, with each batch having a maximum of 10 files.

import Uppy from '@uppy/core'
import '@uppy/core/dist/style.css'
import '@uppy/dashboard/dist/style.css'
import Dashboard from '@uppy/dashboard'
import ImageKitUppyPlugin from "imagekit-uppy-plugin"

const uppy = Uppy({ debug: true, autoProceed: false })
    .use(Dashboard, {
        inline: true,
        trigger: '#uppyDashboard', // your element
    })
    .use(ImageKitUppyPlugin, {
        id: 'ImageKit',
        authenticationEndpoint: `http://www.yourserver.com/auth`,
        publicKey: "your_public_key",
        limit: 10
    })

Support

If something doesn't work as expected, please reach out to us at [email protected] or create an issue in this repo. Please try to include a reproducible code sample.