Skip to main content

Uploading Files and Folders

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.

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 buffer = fs.readFileSync("path/of/your/file.extension")
let data = new FormData()
data.append("file", buffer, "filename")

startonApi
.post("/v3/ipfs/file", data, {
headers: {
"Content-type": `multipart/form-data; boundary=${data.getBoundary()}`,
},
})
.then((res) => console.log(res.data))
.catch((e) => console.log(e))