question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Heya! Awesome library! Transloadit hits again 😃 I’m long user and supporter of node-formidable which was created by @felixge, stating it was created for Transloadit. And it’s pretty awesome, still, after so many years. Strongly believe that it should be rewritten, but anyway.

I’m playing with the API and looks great and easy. I’m thinking to try to create IPFS plugin, but documenting it here for reminder and if anyone else want it.

const upload = (buff, opts) => {
  const options = Object.assign({
    permanent: false,
    protocol: 'https',
    host: 'ipfs.infura.io',
    port: 5001
  }, opts)

  const ipfs = IpfsApi(options)

  ipfs.files.add(buff).then((result) => {
    const hash = result[0].hash
    const url = `https://ipfs.io/ipfs/${hash}`
    console.log('step 1', url)
      
    // behind option called `permanent: true`?
    if (options.permanent === true) {
      ipfs.pin.add(hash).then((res) => {
        console.log('step 2', res[0].hash)
      })
    }
  })
}

Also would be great to support upload from url which in turn is pretty easy with ipfs.util.addFromUrl

const ipfs = IpfsApi({
  protocol: 'https',
  host: 'ipfs.infura.io',
  port: 5001
})

ipfs.util.addFromURL('https://avatars3.githubusercontent.com/u/5038030')
.then(console.log)

related is https://github.com/ipfs/js-ipfs-api/issues/674 - for adding support for pin option to addFromURL utility

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:15

github_iconTop GitHub Comments

5reactions
sponnetcommented, Sep 18, 2018

Hey @tunnckoCore ,

I did some experimenting with it - and what works really well is just using the XHRUpload plugin for that:

    const XHRUpload = require("@uppy/xhr-upload");

    uppy.use(XHRUpload, {
      endpoint: "https://ipfs.infura.io:5001/api/v0/add",
      formData: true,
      metaFields: []
    });

    uppy.on("upload-success", (file, body) => {
        console.log(body.Hash); // is the IPFS hash of the uploaded file
    });

This uploads to IPFS - and you get all the features of the XHRUpload plugin like progress monitoring etc.

Kudos for the super nice uppy project !

3reactions
tunnckoCorecommented, Dec 23, 2018

Ookey, but one more thing. How can we direct all to the XHRUpload so that all files from all the sources will be uploaded to the IPFS?

Sweeeeeet! 🎉 Passing the Infura to serverUrl works. Just thought it won’t that’s why i commented.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IPFS Companion
ABOUT IPFS Companion harnesses the power of your locally running IPFS node (either through the IPFS Desktop app or the command-line daemon) ...
Read more >
IPFS Companion - GitHub
Browser extension that simplifies access to IPFS resources on the web - GitHub - ipfs/ipfs-companion: Browser extension that simplifies access to IPFS ......
Read more >
IPFS Companion
The IPFS Companion browser extension allows you to interact with your IPFS node and the extended IPFS network through your browser. Learn how...
Read more >
IPFS Companion – Get this Extension for Firefox (en-US)
IPFS Companion harnesses the power of your locally running IPFS node (either through the IPFS Desktop app or the command-line daemon) directly inside...
Read more >
IPFS in Code Plugins - UE Marketplace - Unreal Engine
IPFS is a decentralized storage protocol, that allows you to upload, ... Important note: from December 2022 IPFS plugin will be provided for ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found