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

File upload, How to config a server handle url? #826

Open
ilzlsm opened this issue Jan 5, 2019 · 5 comments
Open

File upload, How to config a server handle url? #826

ilzlsm opened this issue Jan 5, 2019 · 5 comments

Comments

@ilzlsm
Copy link

ilzlsm commented Jan 5, 2019

No description provided.

@theamnesic
Copy link

Hi!

Unfortunately, the example doesn't work.

I've got large files, so I can't use base64, I have to upload files on the server.

I've got this schema:

"Image": {
  type: "string",
  format: "url",
  options: {
    upload: true
  },
  "links": [
    {
        "href": "{{self}}"
    }
  ]
}

and this handler:

  JSONEditor.defaults.options.upload = function(type, file, cbs) {
    if (type === 'root.upload_fail') cbs.failure('Upload failed');
    else {
      var tick = 0;

      var tickFunction = function() {
        tick += 1;
        // console.log('progress: ' + tick);

        if (tick < 100) {
          cbs.updateProgress(tick);
          window.setTimeout(tickFunction, 50)
        } else if (tick == 100) {
          cbs.updateProgress();
          window.setTimeout(tickFunction, 500)
        } else {
          cbs.success(file.name);
        }
      };

      window.setTimeout(tickFunction)
    }
  };

Can you tell me if the schema is good, and the right way to upload the file please ?

For example, format: "file" looks more logical but hide the Upload button.
I can't find documentation about that...

Thanks!

— G

btsimonh pushed a commit to btsimonh/json-editor that referenced this issue May 26, 2021
@theamnesic

This comment has been minimized.

@schmunk42
Copy link
Collaborator

@theamnesic I think you're in the wrong repo, please check it here: https://github.com/json-editor/json-editor

@theamnesic
Copy link

@schmunk42 Yep, sorry !

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

3 participants