Git Product home page Git Product logo

Comments (2)

birdylife avatar birdylife commented on June 9, 2024

I had an Error 422 about 5 days ago, and I tracked it down to a change in how overleaf processes the XHtml request.
I changed my code of uploadImage() as follows:

`function uploadImage(imageBlob,hash){

try{
    var xhr = new XMLHttpRequest();
    var url = document.location.pathname + "/upload?folder_id=" + _ide.fileTreeManager.findEntityByPath("assets").id; //+ "&_csrf=" + csrfToken;
    let formData = new FormData();
    formData.append("targetFolderId", _ide.fileTreeManager.findEntityByPath("assets").id);
    formData.append("name", hash + ".png");
    formData.append("type", "image/png");
    formData.append("qqfile", imageBlob, hash + ".png");
    xhr.open("POST", url, true);
    xhr.setRequestHeader('x-csrf-token', csrfToken);
    //xhr.setRequestHeader("Content-Type", "application/json");
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
            var json = JSON.parse(xhr.responseText);
            console.log(json.entity_id + " Asset created :)");
        }
    };
    xhr.send(formData);
}catch(e)
{
    console.log(e)
}

Edit: Struggeling with posting code...
Hope this helps

from overleaf-image-helper.

cmprmsd avatar cmprmsd commented on June 9, 2024

Just merged an update PR for Code Mirror 6. So the current version of Overleaf should now be fully supported!

from overleaf-image-helper.

Related Issues (9)

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.