Uploading video via media.upload() not working.

Open
#267 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
grpc, typescript
Domain
api

Research direction

Start with the media.upload() documentation and its supported media types, then reproduce the reported failures with the sample webm and mp4 uploads using the shown TypeScript call. Done means the supported video behavior is verified and either video uploads work as documented or the documentation accurately states their limitations.

Written by the indexing model from the issue text.

Description

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.

Dominant language
TypeScript
Stars
210
Forks
88
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from reddit/devvit

All issues in reddit/devvit

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.