Skip to main content

Storing your first file on IPFS

You can use Starton to integrate blockchain into your application in a few steps. Let's upload a file from Code with Starton's API.

not a developer?

To follow this tutorial, you will need coding experience. If it's not your case, you can still upload your files:

Step 1 - Initialize the project

  1. Start by creating a directory for your project.

    mkdir upload-ipfs
  2. Then, get into your project directory.

    cd upload-ipfs
  3. With your project directory set up, install the dependencies.

    npm add axios form-data
    • Axios allows you to make request to the Starton API.
    • form-data facilitates the creation and submission of form data using HTTP requests.
  4. Then, usetouch to create a index.js file and open it with your favorite editor.

    touch list.js

Step 2 - Add starton to your project

  1. First, import axios.

    const axios = require("axios")
  2. Then, initialize axios using Starton URL and authenticate with your API KEY.

Create an API key

const starton = axios.create({
baseURL: "",
headers: {
"x-api-key": "YOUR API KEY",

Step 3 - Upload a file to IPFS

Watch your uploads

Files on IPFS are immutable and can be widely replicated. Once uploaded, anyone can access your file and removal is almost impossible challenging. Think twice before sharing!

  1. Grab any file from your computer. You can also generate an image using generative AI.

    const fs = require("fs")
    const FormData = require("form-data")
    const buffer = fs.readFileSync("./path/of/your/file.png")
  2. Prepare the file for the request.

    let data = new FormData()
    data.append("file", buffer, "name of your file")
  3. Send the file to IPFS.

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

    You can also upload folders, JSON files or pin existing files using their CID.

  4. Almost done! Now we can execute it to get your first file stored on IPFS!

    node list.js

    And just like that, your first file is now stored on IPFS!

Check all your files on Starton Web Application

Congratulations on uploading your first file on IPFS! In this tutorial, you discovered how to upload your first file on IPFS but this is only the first step.

Learn how to

Loubna Benzaama

Lead technical writer


December 21, 2023

Reading time:

3 min

  • Step 1 - Initialize the project
  • Step 2 - Add starton to your project
  • Step 3 - Upload a file to IPFS