Skip to content

Uploading video via media.upload() not working. #267

@BesbesCat

Description

@BesbesCat

I read in the docs that media.upload() supports uploading video types with not much documentation on filetypes, limits or any meaningful information on that.

So I tried adding video uploads to my App:

  const uploadPromises = matches.map(async (match) => {
    const dataUrl = match[1];
    const mediaCategory = match[2];
    const extension = match[3]?.toLowerCase();
    let mediaType: 'gif' | 'image' | 'video' = 'image';
    if (mediaCategory === 'video') {Z
      mediaType = 'video';
    } else if (extension === 'gif') {
      mediaType = 'gif';
    }
    console.log('Uploading media:', { mediaType });
    const response = await media.upload({ url: String(dataUrl), type: mediaType });
    return { dataUrl: String(dataUrl), mediaUrl: response.mediaUrl };
  });
  const uploadResults = await Promise.all(uploadPromises);
  for (const res of uploadResults) {
    finalContent = finalContent.replace(res.dataUrl, res.mediaUrl);
  } 

However I tried uploading a sample webm file and it returns:
Failed to upload media: Error: 2 UNKNOWN: stream error: stream ID 10557; PROTOCOL_ERROR; received from peer

I also tried an mp4 file:
Failed to upload media: Error: 2 UNKNOWN: grpc invocation failed with status 2; unable to poll media URL https://i/. redd. it/xxxxx.mp4 failed to poll media after 5 polling timestamps

I tried different file sizes. Even at 900KB it fails. Not sure why this happens. Can anybody confirm if I am doing something wrong?
I am not sure if I am doing something wrong or not. Not even sure if video uploads is even supported and that docs might need updating.
If I am not doing it wrong then you either need to update docs removing video as supported mediaType to avoid confusion or add the support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions