'how do i create directory with ipfs-http-client with infura gateway?
Trying to create a directory with infura. this is from the docs but it does not work...
const run = async () => {
const projectId = 'xxx';
const projectSecret = 'xxx';
const auth =
'Basic ' + Buffer.from(projectId + ':' + projectSecret).toString('base64');
const ipfsClient = require('ipfs-http-client');
const client = ipfsClient.create({
host: 'ipfs.infura.io',
port: 5001,
protocol: 'https',
headers: {
authorization: auth,
},
});
var dir = await client.files.mkdir('/example')
console.log(dir);
// LOG: ipfs method not supported
}
using curl also does not work
curl -X POST -u "xxx:xxx" "https://ipfs.infura.io:5001/api/v0/files/mkdir?arg=/ipfs-examples-dir"
// LOG: ipfs method not supported
what am i missing or doing wrong?
Solution 1:[1]
Hey I ran into this problem a while ago, and found a solution. Not sure if the IPFS HTTP Client has the functionality but this works for me:
const res = await axios.post("https://ipfs.infura.io:5001/api/v0/add?pin=true&wrap-with-directory=true", data, {
headers: {
Authorization: auth
}
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jwarshack |
