<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dave Kjell Marong</title>
    <description>The latest articles on DEV Community by Dave Kjell Marong (@davemarong).</description>
    <link>https://dev.to/davemarong</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F907557%2F13c4b58b-41a0-40a6-8212-0b716ebdf9b7.png</url>
      <title>DEV Community: Dave Kjell Marong</title>
      <link>https://dev.to/davemarong</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/davemarong"/>
    <language>en</language>
    <item>
      <title>Fetch and display video directly from google drive with url in 4 easy steps</title>
      <dc:creator>Dave Kjell Marong</dc:creator>
      <pubDate>Fri, 12 Aug 2022 11:46:00 +0000</pubDate>
      <link>https://dev.to/davemarong/fetch-and-display-video-directly-from-google-drive-with-url-in-4-easy-steps-4aba</link>
      <guid>https://dev.to/davemarong/fetch-and-display-video-directly-from-google-drive-with-url-in-4-easy-steps-4aba</guid>
      <description>&lt;p&gt;I recently made a web app with React, and I needed to display some of my client videos. As google drive is free up to 15GB, this was a perfect fit.&lt;/p&gt;

&lt;p&gt;The problem was that there were no easy solution to fetch and display the videos stored on our google drive account. Here were the options I found:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Embed item&lt;/strong&gt;&lt;br&gt;
This was an easy quickfix, but when embedding from google drive, you also get their own video player. Here you have a link to the video on the google drive account, which can be a security risk as people may find a way to access your google drive account/page. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Google drive api / Google picker&lt;/strong&gt;&lt;br&gt;
This was my first thought, but I quickly realised that would have taken too much time to dive into that ocean of documentation (basically, i'm lazy). &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Get URL and use in "src" attribute&lt;/strong&gt;&lt;br&gt;
There were many differents suggestions on StackOverflow, some of them I tried but they didn't work. But I found one really straight forward way to do it. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Find URL of video and insert into the "src" attribute
&lt;/h2&gt;

&lt;p&gt;This was by far the easiest method. You simply find and edit the video url, and insert it into your Html/React code. Here is how:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1 - Make link/folder public&lt;/strong&gt;&lt;br&gt;
First, we need to give the public permission to see the videos. Navigate to your Google drive folder. Click on the folder-name to open a menu. Here, click on "Share". Then, on the bottom, select "Anyone with a link", then close the window. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foqy7c0w04xznqennjk27.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foqy7c0w04xznqennjk27.png" alt="Make folder public"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2 -  Open video in "new window"&lt;/strong&gt;&lt;br&gt;
In your folder, double click on the video to open it. Then, in the top right corner, click on the "3 dots" icon to open a menu. Almost at the bottom, click on "Open in new window".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh7hpdqpr0hta7s8cu0ci.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh7hpdqpr0hta7s8cu0ci.png" alt="Open video in new window"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3 -  Edit the URL&lt;/strong&gt;&lt;br&gt;
Now copy the URL in the newly opened window. It will look something like this: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://drive.google.com/file/d/1APSRoW8XLWShNkeuC7--84XSoyMdcPrP/view&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, we are going to make 2 changes to this url. You can do it directly in the browser url bar:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First, delete this part:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;file/d/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and replace it with this instead:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;uc?id=&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Secondly, delete the last part of the url:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;/view&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now your url should look like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://drive.google.com/uc?id=1APSRoW8XLWShNkeuC7--84XSoyMdcPrP&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4 - Insert url in "src" attribute&lt;/strong&gt;&lt;br&gt;
Now, in your code, add a video element and paste in the url into the "src" attribute:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;video 
 src="https://drive.google.com/uc?id=1APSRoW8XLWShNkeuC7--84XSoyMdcPrP" controls&amp;gt;
&amp;lt;/video&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That's all, folks!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
