Media uploads


Full code example

Media endpoints will allow the users to upload AUDIO and VIDEO directly to the API without using IPFS or a storage provider. It will create a copy of the file in our cache and streaming system before pinning it to the decentralised IPFS. All on-chain metadata will point to the decentralised IPFS CID, not our cache system.

first, you need to create the media type and then push the file to the signed URL. When the file is fully updated using the SignedURL you then can create the post/comment with the Media on the metadata. We will explain in more detail below.

Once the publication is mined, the Lens API will push the file to an IPFS storage making sure on-chain leverages the decentralised vision.

API details

params on the request

itemCidIfpsCidYou need to precalculate the CID of the file before upload it with the presignedURL
typeMimeTypeMime type of the file to upload
altTagStringAlternative text to show on the embed object
coverUrlUrl cover image



Only works with AUDIO and VIDEO.


Hot tip

If you want to add a Cover first need to be pushed to a IPFS service, we only take care of the Audio/Video attached on the item media.

mutation CreateAttachMediaData($request:  {
    itemCid: "QmTAznyH583xUgEyY5zdrPB2LSGY7FUBPDddWKj58GmBgp",
    type: "video/mp4",
    altTag: "video test",
    cover: "ifps://QmVwvsJrFzAAb1fPe5uXF4QpPib1T6gjc3xLpS96BUsTL6"
  }) {
  createAttachMediaData(request: $request) {
    media {
  signedUrl: '',
  media: {
    item: 'ifps://QmTAznyH583xUgEyY5zdrPB2LSGY7FUBPDddWKj58GmBgp',
    type: 'video/mp4',
    cover: null,
    source: 'LENS',
    altTag: 'video test',




For upload the image need to be done with the http method PUT

Once you get the presignedUrl (more info) , you can upload the file to S3.

const file = fs.readFileSync(path.join(__dirname, 'file/video.mp4'));
const response = await fetch(signedUrl, {method: 'PUT', body: file});

Allowed formats


  • video / webm
  • video / mp4
  • video / x - m4v
  • video / ogv
  • video / ogg


  • audio / wav
  • audio / mpeg
  • audio / ogg
  • audio / midi

Using LensClient SDK

const result = await lensClient.publication.createAttachMediaData({
  itemCid: "QmTAznyH583xUgEyY5zdrPB2LSGY7FUBPDddWKj58GmBgp",
  type: "video/mp4",
  altTag: "video test",
  cover: "ifps://QmVwvsJrFzAAb1fPe5uXF4QpPib1T6gjc3xLpS96BUsTL6"