imagekit-developer / imagekit-uppy-plugin

Uppy plugin for ImageKit destination
MIT License
4 stars 8 forks source link

Plugin only works with very old and obsolete versions of Uppy #20

Open andrew-connell opened 7 months ago

andrew-connell commented 7 months ago

Uppy's plugin architecture changed years ago. I started to try and update this plugin but realised it's much easier to just use @uppy/xhr-upload

This is all that's required:

import Uppy from '@uppy/core'
import XHR from '@uppy/xhr-upload'
const uppy=new Uppy({ debug: true })
 .use(XHR, {endpoint: IMAGEKIT_URL_ENDPOINT})
  .on('file-added', (file) => {
    fetch(ENDPOINT).then((response) => response.json()).then((data) => {
      uppy.setFileMeta(file.id, {
        fileName: file.name,
        publicKey: IMAGEKIT_PUBLIC_KEY,
        signature: data.signature,
        expire: data.expire,
        token: data.token,
      })
    })
  })

It now works perfectly and is future proof. I'm not sure this plugin is necessary at all.