I am using ipfs-http-client to upload an image but the response sends the hash twice instead of name/path like indicated in docs.
https://gyazo.com/5be735de8194f8511d71e98982240e03
const auth =
"Basic " + Buffer.from(projectId + ":" + projectSecret).toString("base64");
const client = ipfsHttpClient({
url:'https://ipfs.infura.io:5001/api/v0',
headers: {
authorization: auth,
},
});
const uploadToIPFS = async (file, setFileUrl) => {
try {
const added = await client.add({ content: file });
console.log(added)
const url = `https://ipfs.infura.io/ipfs/${added.path}`;
return url;
} catch (error) {
console.log('Error uploading Image!');
}
};
I do send a request and response comes however it is not what I expected since the docs promise a path under Name property