I am using IPFS to upload images however it's not working In the console window it's giving me the following error in Jquery.PersistPlugin.js I am not sure where is this file and how to solve this issue need your help!

Uncaught TypeError: Ipfs is not a constructor
    at Object.success (jquery.PersistPlugin.js:33)
    at i (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at y (jquery.min.js:4)
    at HTMLScriptElement.b.onload.b.onreadystatechange (jquery.min.js:4)

this is the IPFS connection code in the app.js

uploaddoc: function(){
    const reader = new FileReader();
    reader.onloadend = function() {
      const ipfs = window.IpfsApi('localhost', 5001) // Connect to IPFS
      const buf = buffer.Buffer(reader.result) // Convert data into buffer
      ipfs.files.add(buf, (err, result) => { // Upload buffer to IPFS
        if(err) {
          swal("Error", "Something went wrong!", "error");
        let url = `https://ipfs.io/ipfs/${result[0].hash}`
        console.log(`Url --> ${url}`)
        $(".js-uploaded-hash").attr("data-hash", result[0].hash);
        swal("Document Uploaded!", "Thanks for choosing us!", "success");
    const photo = document.getElementById("memories");
    reader.readAsArrayBuffer(photo.files[0]); // Read Provided File


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.