Question

Is it possible to embed a video from DigitalOcean Spaces?

In youtube it’s possible to get an <iframe> embed for a video. I would like to embed one of my videos from DigitalOcean Spaces in my website.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
August 8, 2023

Hi there,

Yes, it should be possible to embed a video from DigitalOcean Spaces into your website using the <video> HTML tag rather than as you would with a YouTube video with an <iframe> tag.

The DigitalOcean Spaces is an object storage service, and you can generate URLs for your files that are accessible over the web.

Here’s a general guide on how you might accomplish this:

  1. Make Sure the Video is Public: Ensure that the video file you want to embed is set to be publicly accessible. You can configure this through the DigitalOcean Spaces dashboard or through their API.

  2. Get the URL of the Video: Once the video is public, you will have a URL that directly points to that video file.

  3. Use HTML5 Video Tag: Instead of an <iframe>, you would typically use the <video> tag to embed a video from a direct URL. Here’s an example:

<video width="640" height="360" controls>
    <source src="https://your-space-name.nyc3.digitaloceanspaces.com/your-video.mp4" type="video/mp4">
    Your browser does not support the video tag.
</video>

Replace the src attribute with the direct URL to your video in DigitalOcean Spaces.

  1. Depending on the configuration of your DigitalOcean Spaces and the website where you’re embedding the video, you might need to consider CORS policies. You may need to adjust the settings in DigitalOcean Spaces to allow access from your website’s domain:

    https://docs.digitalocean.com/products/spaces/how-to/configure-cors/

As a follow up, you can further customize the video player by using JavaScript libraries like Video.js or Plyr to provide a more interactive and styled video player.

Hope that this helps!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel