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

Am i the only one struggling with the image/upload? #25

Closed
screechyboy79 opened this issue Mar 14, 2018 · 10 comments
Closed

Am i the only one struggling with the image/upload? #25

screechyboy79 opened this issue Mar 14, 2018 · 10 comments

Comments

@screechyboy79
Copy link

Love the WYSIWYG however naturally I dont want to upload my images to your webserver and am finding the documentation confusion... where can i change the settings for this so that it uploads new images to my server and it browses my own webserver for already uploaded images?

@xdan
Copy link
Owner

xdan commented Mar 17, 2018

You need connector on your server. https://github.com/xdan/jodit-connectors

@dannystyleart
Copy link
Contributor

Hello @xdan,
I have opened a similar issue #31 .
Is this sure that there should be no option to customize the way of upload?

Like it would be fine to just make an option to pass a function that gets the selected files as an argument and a reject/resolve params

the resolve must get an src that can be used for images and the error could get any object that is passed to handleError.

@xdan
Copy link
Owner

xdan commented Mar 21, 2018

Hi, in last example i tried show how change default sender https://xdsoft.net/jodit/doc/types/UploaderOptions/

@dannystyleart
Copy link
Contributor

@xdan
Just seen, that the documentation was updated. At the moment I have no chance to make a test drive but noticed, that I have forgot what I need to achieve:

I have to send the upload request in the following format:

CORS request to a json REST API with POST method with the following request payload:

{ type: 'entity-name', attributes:{ image: 'data:base64/jpeg.......' } }

Currently I can't receive the selected files to read in and convert to base64.

Is there any plan to get it?

@xdan
Copy link
Owner

xdan commented Mar 22, 2018

In 3.1.77 buildData can return Promise
https://xdsoft.net/jodit/doc/types/UploaderOptions/
But i think it works not in all browsers. i checked in last Firefox and last Chrome

@dannystyleart
Copy link
Contributor

@xdan I have tried that example and hell yeah, it works!
One thing that I could not really understand but now its clear:
In the Ajax.ts I have found that when the ajax request is done you match the status code only via 200 ( success ). This makes a false positive error because we are getting 201 ( created ) response from backend so this success code should be configurable or a range of 20x status codes that are originally all meant to be code for successful responses.

Should I make a PR on that?

@xdan
Copy link
Owner

xdan commented Apr 3, 2018

I will be very grateful to you

@dannystyleart
Copy link
Contributor

@xdan I have made the commit but I can't push to the repo, neither create a PR.
Could you grant permisisons?

@xdan
Copy link
Owner

xdan commented Apr 3, 2018

You need create fork, https://c2n.me/3TaghB6, clone it and make some branch
git checkout -b ajax_feature
after you fixes do commit and pull this branch to your forked repository, after this when you will sign in your account you will see Pull Request button above your fork.

dannystyleart added a commit to dannystyleart/jodit that referenced this issue Apr 3, 2018
@xdan xdan closed this as completed in #33 Apr 3, 2018
xdan added a commit that referenced this issue Apr 3, 2018
*Fixed #25 - Better image upload response status check
@IvanBarbaric992
Copy link

IvanBarbaric992 commented Apr 10, 2020

Hello @xdan, I have a problem, working in react-redux and .net core. I have a file sistem in .net core which is able to take id parameter and list of files send from react side. In these case files are images from jodit.

public class Request { public int Id { get; set; } [Required] public List<IFormFile> Files{ get; set; } }
This is request in core, and it works with postman without any problem, when I try upload image/images from jodit editor it binds id but files are not binded. Can you please help me out because I can not find the solution. This is my code from uploader:
`uploader: {

        url: `somepath`,
        // insertImageAsBase64URI: false,
        imagesExtensions: ["jpg", "png", "jpeg", "gif"],
        // withCredentials: true,
        filesVariableName: function (e) {
          return "Files";
        },

        headers: {
          Authorization:
            "bearer token",
        },

        prepareData: function (data) {
          data.append("id", 16);
          console.log(data);
          return data;
        },

        isSuccess: function (resp) {
          return resp;
        },
        process: function (resp) {
          return {
            files: resp.files,
            path: resp.path,
            baseurl: resp.baseurl,
            error: resp.error,
            message: resp.message,
          };
        },

        defaultHandlerSuccess: function (data) {
          var i,
            field = "files";
          if (data[field] && data[field].length) {
            for (i = 0; i < data[field].length; i += 1) {
              this.selection.insertImage(data.baseurl + data[field][i]);
            }
          }
        },
      },`

Thank you in advance.

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