Creating folders on IPFS
You can upload content on IPFS. Starton IPFS is a storage and pinning service, where you can host files, folders, and metadata on our IPFS nodes so that they remain available at all times.
- From Code
- From Webapp
POST requests with a body should have the Content-Type header with value application/json. For sending files it should be multipart/form-data.
const axios = require("axios")
const FormData = require("form-data")
const fs = require("fs")
// AUTHENTICATING TO THE API USING YOUR API KEY
const startonApi = axios.create({
baseURL: "https://api.starton.com",
headers: {
"x-api-key": "YOUR_API_KEY",
},
})
const folderPath = "my/folder/path"
let data = new FormData()
const files = fs.readdirSync(folderPath)
data.append("folderName", "folder name")
for (const file of files) {
const buffer = fs.readFileSync(folderPath + "/" + file)
data.append("files", buffer, file)
}
data.append("metadata", metadata)
startonApi
.post("/v3/ipfs/folder", data, {
headers: {
"Content-type": `multipart/form-data; boundary=${data.getBoundary()}`,
},
})
.then((res) => console.log(res.data))
.catch((e) => console.log(e))
- Go to IPFS.
- Click Upload.
- Select File(s).
- Toggle the Create folder button.
- Enter Names for the files.
- Click Upload.