INFURA / infura

Official Public Repository for INFURA
https://infura.io
380 stars 62 forks source link

IPFS Mutable File system code stoped working #147

Closed ramxis closed 6 years ago

ramxis commented 6 years ago

Hi

I keep getting the error "SyntaxError: Unexpected token < in JSON at position 0" when using ipfs.files.write() with Infura Node. Here Is my code: ipfs = new IPFS({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' }); const data = "Initializing Sensor and Shipping data logging for package Nr." + trackingNr.toString() + "\n"; const buffer = Buffer.from(data,'utf-8');

//ipfs.files.write(ipfsLogPath, Buffer.from(data,'utf-8'),{create:true}, function(err) {
ipfs.files.write(ipfsLogPath,buffer,{create:true}, function(error) {
  if(error)
  {
    console.log('IPFS write error:' + error);
    console.log(buffer);
    console.log(ipfsLogPath);
  }
  console.log("IPFS log Init");
});

This code was working perfectly about a month ago. Why did this code suddenly stopped working? Any help will be greatly appreciated.

ncocchiaro commented 6 years ago

The /files methods as well as other stateful portions of the IPFS RPC API are not supported via the Infura endpoint. My suggestion would be to use some of the other write RPCs like /add or /object/put and keep track of hashes and other content identifiers as needed. We've recently published documentation on the subset of the Ethereum and IPFS APIs that our backend supports: https://infura.io/docs/.