SDK Reference
Methods
UploadMedia

uploadMedia

Used to upload new media to IPFS using Pinata which can then be used in an Orbis post.

How to use?

This method requires additional configuration during Orbis SDK initialization. Check #Examples.

const res = await orbis.uploadMedia(file);

Parameters

  • file - a File object obtained via file input (or compatible methods)

Returns

{
  status: 200,
  result: {
    url: "ipfs://Qm......e0",
    gateway: "https://.../ipfs"
  }
}

Examples

If you don't have one already, setup a Pinata (opens in a new tab) gateway here to obtain required credentials.

Upload and attach a file to a Post

/** Set up Orbis SDK with your Pinata gateway credentials */
const orbis = new Orbis({
  PINATA_GATEWAY: pinata_gateway, // Your Pinata Gateway
  PINATA_API_KEY: pinata_api_key, // Your Pinata API key
  PINATA_SECRET_API_KEY: pinata_secret_api_key // Your Pinata Secret API key
});
 
/** Upload a file to IPFS (file can be obtained via <input type="file" /> or compatible alternatives) */
const uploadedFile = await orbis.uploadMedia(file);
 
/** Add the results in a media array used when sharing the post (the media object must be an array) */
const res = await orbis.createPost({
  body: "Post with a media!",
  media: [uploadedFile.result]
});