Skip to content

Need help customize the image toolbar button to load an url asynchronously #991

Closed Answered by karthikcodes6
rhlc asked this question in Q&A
Discussion options

You must be logged in to vote

You can optionally pass a callback to the image upload plugin

 createImagePlugin({
    uploadImage: handleUploadImage
  })

The callback should be like this

const handleUploadImage = async (e) => {
  const data = new FormData();
  data.append('image', e);
  const response = await API.post('/upload/file', data, {
    headers: { ['Content-Type']: 'multipart/form-data' }
  });
  return response.data?.data?.message;
};

You should return the url after uploaded to the storage service.

Replies: 2 comments 13 replies

Comment options

You must be logged in to vote
2 replies
@ashikraj78
Comment options

@karthikcodes6
Comment options

Answer selected by rhlc
Comment options

You must be logged in to vote
11 replies
@karthikcodes6
Comment options

@hdck007
Comment options

@woodpeng
Comment options

@danielbayerlein
Comment options

@woodpeng
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
help wanted Extra attention is needed plugin:image
6 participants