Skip to content

getUploadWidgetOptions, generateSignatureCallback, generateUploadWidgetResultCallback#165

Merged
colbyfayock merged 6 commits intobetafrom
feat/164-getuploadwidgetoptions
Aug 2, 2024
Merged

getUploadWidgetOptions, generateSignatureCallback, generateUploadWidgetResultCallback#165
colbyfayock merged 6 commits intobetafrom
feat/164-getuploadwidgetoptions

Conversation

@colbyfayock
Copy link
Collaborator

@colbyfayock colbyfayock commented Jul 25, 2024

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.

  • getUploadWidgetOptions: this takes in a set of options that deal with the configuration of the upload widget, including account credentials and signature callback function
  • generateSignatureCallback: this generates a new callback function that given an endpoint and fetcher (like the fetch API), will make it easier to pass the resulting function to the widget options above
  • generateUploadWidgetResultCallback: when uploading with the widget, different events are produced depending on the state of the upload, this helps manage all of the different events via a single callback function with the ability to pass in and tap into the different events

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);

*/

export interface GenerateSignatureCallback {
fetch: Function;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be able to use typeof fetch here which should be globally available

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, though my original thinking was someone could pass in something that's not fetch. realistically its going to be fetch and the shape supports fetch "as is", so perhaps i just move forward with the suggestion and can look at other use cases should they ever come up

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually it's not working in the environment, i wonder if i would need to install the node-fetch types for this to work or something. im gonna leave it as Function for now just to merge this into a beta. open to ideas and improvements here though

image

Copy link

@Baroshem Baroshem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small question, apart from that Approve :)

@colbyfayock colbyfayock changed the base branch from main to beta August 2, 2024 15:49
@colbyfayock colbyfayock merged commit 4e3adc4 into beta Aug 2, 2024
@colbyfayock colbyfayock deleted the feat/164-getuploadwidgetoptions branch August 2, 2024 15:53
github-actions bot pushed a commit that referenced this pull request Aug 2, 2024
# [@cloudinary-util/url-loader-v5.4.0-beta.1](https://github.com/cloudinary-community/cloudinary-util/compare/@cloudinary-util/url-loader-v5.3.1...@cloudinary-util/url-loader-v5.4.0-beta.1) (2024-08-02)

### Features

* getUploadWidgetOptions, generateSignatureCallback, generateUploadWidgetResultCallback ([#165](#165)) ([4e3adc4](4e3adc4)), closes [#164](#164)
github-actions bot pushed a commit that referenced this pull request Aug 2, 2024
# [@cloudinary-util/types-v1.2.0-beta.1](https://github.com/cloudinary-community/cloudinary-util/compare/@cloudinary-util/types-v1.1.0...@cloudinary-util/types-v1.2.0-beta.1) (2024-08-02)

### Features

* getUploadWidgetOptions, generateSignatureCallback, generateUploadWidgetResultCallback ([#165](#165)) ([4e3adc4](4e3adc4)), closes [#164](#164)
@github-actions
Copy link

github-actions bot commented Aug 2, 2024

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

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Aug 2, 2024
# [@cloudinary-util/url-loader-v5.5.0-beta.1](https://github.com/cloudinary-community/cloudinary-util/compare/@cloudinary-util/url-loader-v5.4.0...@cloudinary-util/url-loader-v5.5.0-beta.1) (2024-08-02)

### Features

* getUploadWidgetOptions, generateSignatureCallback, generateUploadWidgetResultCallback ([#165](#165)) ([4e3adc4](4e3adc4)), closes [#164](#164)
@github-actions
Copy link

github-actions bot commented Aug 2, 2024

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

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request Aug 2, 2024
# [@cloudinary-util/util-v3.2.0-beta.1](https://github.com/cloudinary-community/cloudinary-util/compare/@cloudinary-util/util-v3.1.0...@cloudinary-util/util-v3.2.0-beta.1) (2024-08-02)

### Features

* getUploadWidgetOptions, generateSignatureCallback, generateUploadWidgetResultCallback ([#165](#165)) ([4e3adc4](4e3adc4)), closes [#164](#164)
@github-actions
Copy link

github-actions bot commented Aug 2, 2024

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

The release is available on:

Your semantic-release bot 📦🚀

colbyfayock pushed a commit that referenced this pull request Aug 2, 2024
# [@cloudinary-util/url-loader-v5.5.0-beta.1](https://github.com/cloudinary-community/cloudinary-util/compare/@cloudinary-util/url-loader-v5.4.0...@cloudinary-util/url-loader-v5.5.0-beta.1) (2024-08-02)

### Features

* getUploadWidgetOptions, generateSignatureCallback, generateUploadWidgetResultCallback ([#165](#165)) ([4e3adc4](4e3adc4)), closes [#164](#164)
github-actions bot pushed a commit that referenced this pull request Aug 2, 2024
# [@cloudinary-util/util-v3.2.0-beta.1](https://github.com/cloudinary-community/cloudinary-util/compare/@cloudinary-util/util-v3.1.0...@cloudinary-util/util-v3.2.0-beta.1) (2024-08-02)

### Features

* getUploadWidgetOptions, generateSignatureCallback, generateUploadWidgetResultCallback ([#165](#165)) ([4e3adc4](4e3adc4)), closes [#164](#164)
github-actions bot pushed a commit that referenced this pull request Aug 2, 2024
# [@cloudinary-util/types-v1.2.0-beta.1](https://github.com/cloudinary-community/cloudinary-util/compare/@cloudinary-util/types-v1.1.0...@cloudinary-util/types-v1.2.0-beta.1) (2024-08-02)

### Features

* getUploadWidgetOptions, generateSignatureCallback, generateUploadWidgetResultCallback ([#165](#165)) ([4e3adc4](4e3adc4)), closes [#164](#164)
github-actions bot pushed a commit that referenced this pull request Aug 2, 2024
# [@cloudinary-util/url-loader-v5.6.0-beta.1](https://github.com/cloudinary-community/cloudinary-util/compare/@cloudinary-util/url-loader-v5.5.0...@cloudinary-util/url-loader-v5.6.0-beta.1) (2024-08-02)

### Features

* force version ([cb63bff](cb63bff))
* getUploadWidgetOptions, generateSignatureCallback, generateUploadWidgetResultCallback ([#165](#165)) ([4e3adc4](4e3adc4)), closes [#164](#164)
@github-actions
Copy link

github-actions bot commented Aug 2, 2024

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

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getUploadWidgetOptions

3 participants