DEV Community


Posted on

Pastebin As a Media Host


After purchasing a pastebin pro account a few months ago during a sale for relatively cheap I tried to see what I could use it for.

I discovered that by sending the raw data of a media file through their API the raw page of that bin would properly display! You'll need at least a free account so you can get a dev key from their api pages.

This is interesting because using the web interface to paste a media file doesn't work!

I've made a barebones php script that lets you play with this, there's a lot to be desired but it should work enough to let you try to upload your own images. Just remember paste bins size limits are pretty small if you don't have a pro account!

GitHub logo agentd00nut / pasteStore

Barebones CLI php script to upload to pastebin.


Easily send files, including images and most media types, to pastebin.


Get your developer key from the api pages and save it into the devKey file.

If you want to make private posts do the same but for your user key and save it into the userKey file.


Passing data in from a pipe sets a random name and the contents to STDIN. cat myImage.jpg | pasteStore.php

Passing data in from a pipe with an arg sets the paste name to the arg and the contents to STDIN. cat myImage.webm | pasteStore.php thisIsMyCoolPaste

Passing just an arg treats the argument as the path to a file and pulls its contents. pasteStore.php myImage.mp4

Manually edit the code to change if its uploading as private or if its going to expire.

Better yet, write some argument handling and make a pull request!


For images, gifs, and webms you can visit the links directly and they work. For .mp4, .webp, and others you need to embed them into a webpage for them to work.

I only tried png and jpg's. I'm sure nearly any common image format would work.



mp4 and others

.mp4, .webp, and other video formats don't work directly. Instead I found you need to wrap them in video elements and set the source like this...

<video width="320" height="240" controls>
    <source src="" type="video/mp4">
Enter fullscreen mode Exit fullscreen mode


Is this useful? Sorta! I like the idea of being able to upload a whole bunch of my images on a server I don't pay bandwidth on!

It's much less useful if you don't have a pro account since you have a 500kb max upload size.

You could do something goofy though like pool a few peoples pro accounts together and host one of those image storage sites that, on the backend, just links to unlisted paste bin posts.

Maybe you could write a web player that seamlessly plays all the videos in a list, and then divide bigger files into 10mb chunks and host large videos right off pastebin.

For now It's mostly just interesting and a decent way to quickly share an image with someone. I think if pastebin adds support for API uploading into folders it could become much more useful.

Top comments (0)