cloudinary-community / cloudinary-util

https://cloudinary-util.vercel.app
MIT License
12 stars 19 forks source link

getUploadWidgetOptions, generateSignatureCallback, generateUploadWidgetResultCallback #165

Closed colbyfayock closed 4 months ago

colbyfayock commented 4 months ago

Description

This creates a new set of helpers that will help framework libraries reduce the boilerplate needed to instantiate new instances of the upload widget.

Issue Ticket Number

Fixes #164

Usage

const signatureCallback = generateSignatureCallback({
  signatureEndpoint: '/asdf',
  fetch
})

const uploadOptions = getUploadWidgetOptions({
  signatureCallback
}, {
  cloud: {
    cloudName: 'testcloud',
    apiKey: 'abcd1234'
  }
});

const resultsCallback = generateUploadWidgetResultCallback({
  onError: (uploadError) => {
    // Example on storing error
    // setError(uploadError);
  },
  onResult: (uploadResult) => {
    // Example of storing results on any event
    // setResults(uploadResult);
  },
  onSuccess: (uploadResult) => {
    // Tapping into individual events
  }
});

cloudinary.createUploadWidget(uploadOptions, resultsCallback);
github-actions[bot] commented 4 months ago

:tada: This PR is included in version @cloudinary-util/types-v1.2.0-beta.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 4 months ago

:tada: This PR is included in version @cloudinary-util/url-loader-v5.5.0-beta.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 4 months ago

:tada: This PR is included in version @cloudinary-util/util-v3.2.0-beta.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 4 months ago

:tada: This PR is included in version @cloudinary-util/url-loader-v5.6.0-beta.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: