I’m trying to retrive an audio file from my ipfs repo using the javascript implementation of the http api. I’m using files.get, passing the path to my hash but am never returned anything. given the code below, can you see anything i’m doing wrong?
const NodeID3 = require('node-id3'),
ipfsAPI = require('ipfs-api')
const ipfs = ipfsAPI({
host: "127.0.0.1",
port: 5001,
protocol: 'http'
})
let self = {
getId3Data : track => {
ipfs.files.get(`/ipfs/${track.audioHash}`, (err, files) => {
if (err) {
console.error(err)
return false;
}
console.log(files.path)
console.log(files.content.toString('utf8'))
// files.forEach((file) => {
// console.log(file.path)
// console.log(file.content.toString('utf8'))
// })
// let buffer = new Buffer(file.content)
// let tags = NodeID3.read(buffer)
// console.log(file, buffer, tags);
})
}
}
as you can see i’ve tried a few things, files.forEach gives me files.forEach is not a function and just reading .path and .content are undefined… i tried like this because i am only ever working with one file, i know the docs say it’s suppose to come back as an array. This is what files comes back as in the console.
ObjectsStreams {
_readableState:
ReadableState {
objectMode: true,
highWaterMark: 16,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: null,
pipesCount: 0,
flowing: null,
ended: false,
endEmitted: false,
reading: false,
sync: true,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
destroyed: false,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined }
if anybody could point me in the right direction that would be great!