orbis.uploadMedia()

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

How to use?

To use the uploadMedia() function, developers must first setup a Pinata gateway here and the credentials must be passed when initializing the main Orbis object.

/** Configuring the Orbis object to use the Pinata credentials */
let orbis = new Orbis({
  PINATA_GATEWAY: pinata_gateway,
  PINATA_API_KEY: pinata_api_key,
  PINATA_SECRET_API_KEY: 'pinata_secret_api_key
});

/** Then developers can use the uploadMedia function */
let res = await orbis.uploadMedia(file);

/** Add the results in a media array used when sharing the post (the media object must be an array) */
let res = await orbis.createPost({
  body: "Post with a media!",
  media: [res.result]
});

Parameters

  • file: A file object obtained using a tradditional file input.

Returns

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