Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to customize image upload request? #31

Closed
dannystyleart opened this issue Mar 20, 2018 · 3 comments
Closed

How to customize image upload request? #31

dannystyleart opened this issue Mar 20, 2018 · 3 comments

Comments

@dannystyleart
Copy link
Contributor

dannystyleart commented Mar 20, 2018

Hello @xdan,

I like this wyswyg editor, it is fast and fullpacked but I can't figure out how to customize the image upload.

The default implementation forces a multipart formdata as request payload and somehow flips rabdomly a get request before the post when using cors.

I have to pass a json object in the request body and inside it the image base64 encoded.
Is there anyway to override the uploader class to use own custom logic?

Im using it wit react and axios as http client. It would be cool to pass a custom uploader class that gets the files.

Thanks in advance

@dannystyleart dannystyleart changed the title How to cuatomize image upload request? How to customize image upload request? Mar 20, 2018
@einarhuseby
Copy link

einarhuseby commented Mar 22, 2018

I haven't tried it but the afterInsertImage event could work. From the docs you have the image object and I guess you could take the image.src remove the data:image/..;base64, and upload it with your own uploader then change image.src to the url serving your uploaded image which will be inserted (or changed) in the editor.

@xdan, it would be very nice to have an event along the lines of afterInsertFile where you get the file object which one can upload using a custom uploader and then return whatever you want to be inserted in the editor. For an attachment maybe filename with url to file, for an image insert the image with src to the url serving the image etc.

@xdan
Copy link
Owner

xdan commented Apr 5, 2018

Hi here https://xdsoft.net/jodit/doc/types/UploaderOptions/ in latest example you can find getting file from FormData object

@xdan xdan closed this as completed Apr 9, 2018
@sowmiyaseshadriii
Copy link

sowmiyaseshadriii commented Jan 6, 2020

Hi @xdan @dannystyleart is it possible to apply custom url for image upload, i.e i dont want to upload in https://xdsoft.net/jodit/connector/index.php?action=fileUpload instead i want use custom url eg xyz.com/upload, for this i need to pass data, filename also, how can be done,

uploader: {
            url:  "xyz.com/upload"
            headers: {
              Authorization: 
               "2wnz2gu8"
            }, 


Jodit.js
Config_1.Config.prototype.uploader = {
    url: 'xyz.com/upload',
   headers: {
              Authorization: 
               "2wnz2gu8"
            },
data: {
 filename: "",
 encodedstr: ""
},
 insertImageAsBase64URI: false,
 imagesExtensions: ['jpg', 'png', 'jpeg', 'gif'],
   withCredentials: false,
    format: 'json',
    method: 'POST',
process: function (resp) {
        return resp.data;
    },
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants