Code Monkey home page Code Monkey logo

Comments (10)

thangngoc89 avatar thangngoc89 commented on May 24, 2024

Here is an example code :

 <script type="text/javascript">
    editor = new Dante.Editor(
      {
        el: "#editor",
        upload_url: "/images.json", //it expect an url string in response like /your/server/image.jpg or http://app.com/images/image.jpg

      }
    );
    editor.start()
  </script>

Dante will send a post request to /images.json , your server receive it and return a image link (like /your/server/image.jpg ).

from dante.

akkias avatar akkias commented on May 24, 2024

Wow! sir that was so fast, and I am eagerly waiting for an image actions

from dante.

michelson avatar michelson commented on May 24, 2024

Hi @akkias , thanks for your kind comment.
As @thangngoc89 said the upload_url attribute will set the path where you have your image uploader which will return the upload image path in response.
If you need more help on this just reopen this ticket.

best!

from dante.

thangngoc89 avatar thangngoc89 commented on May 24, 2024

@michelson is there any plan on the response mapping? Currently, our api send back a json data and we don't want to edit the api.

from dante.

michelson avatar michelson commented on May 24, 2024

@thangngoc89 currently there are no plans to change that behavior.
do you have some ideas of how the response mapping would be ? patches welcome!

from dante.

thangngoc89 avatar thangngoc89 commented on May 24, 2024

@michelson here is my example :
I assume my api return this data :

{
'link' : 'http://your.server/image.jpg'
}

There will be a callback function like :

<script type="text/javascript">
    editor = new Dante.Editor(
      {
        el: "#editor",
        upload_url: "/images.json", //it expect an url string in response like /your/server/image.jpg or http://app.com/images/image.jpg
        upload_callback: function(data)
        {
            return data.link;
        }
      }
    );
    editor.start()
  </script>

If there is no upload_callback, default behaviour will be triggered

from dante.

michelson avatar michelson commented on May 24, 2024

looks good, maybe we could use the same upload_url to accepts a string or function

from dante.

thangngoc89 avatar thangngoc89 commented on May 24, 2024

yes, a lot of js package do it this way. Just pass the result into a closure (if there is any) and do the same job.

from dante.

michelson avatar michelson commented on May 24, 2024

@thangngoc89 please check the branch upload_url_mapping and test it using bundle exec rackup config.ru I think this is what you are looking, I'll merge this later.

from dante.

michelson avatar michelson commented on May 24, 2024

@thangngoc89 the upload_callback option was released as 0.0.10 , thanks !

from dante.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.