How to download view only files from SharePoint, Google Drive, Dropbox or any other cloud storage

If you have used cloud storage for storing your files or if someone has shared a file to you which is located on cloud storage then you are a little bit familiar with cloud storage service. You can store your files on cloud storage and there are various options available for you.

Some of the most commonly used cloud storage services include Google Drive, Dropbox, Onedrive or SharePoint. The common difference between these services is that Google Drive is provided by Google, OneDrive and SharePoint by Microsoft. Google Drive integrates with Google apps whereas SharePoint and OneDrive integrates with Microsoft apps. 

Most of the people prefer using Google Drive as it offers more space and functionalities. 

You can also share files with others using these cloud-based storage services. 

When you share a file from such a cloud storage service then you can set the options whether a receiver can edit, download or view this file or not. If you don’t want to allow a receiver to download a file shared with him then you can set the file sharing option to view only file.

In this article we will talk about:

Downloading a view only file from Google drive

Downloading a view only file from SharePoint or OneDrive

Downloading a view only file from DropBox

Let’s check how we can do this.

What does a “view only file shared with you” mean?

A file, which is shared with you through a link from a cloud storage service like Google Drive, with option view only or protected can’t be downloaded. Such type of file can be viewed only nor you can edit it nor download. 

The download or print option is disabled for such a type of file. 

A view only file can be a Google doc file, Google sheet file, PPT file, Excel or word file, PDF file or a video file. 

Ways to get download access to a view only file

It is obvious that you have only one way if you want to download the original view only file and that way is to get download permission from the owner who has shared the file with you. 

The other way which we will talk about is to make a copy of that file.

Downloading view only files from SharePoint, Google Drive, Dropbox or OneDrive

As we have already mentioned we will make copy of that file so keep in mind:

Note: This article is for informational purpose. The method discussed in this article will generate a copy of the view only file using JS code and then download that file.

We will run the following code in Console for this purpose.

To open Console on Chrome:

  • Open Chrome
  • Click Right with mouse and tap on Inspect
  • Tap on Console and then clear it

For Bing:

  • Open Bing Browser
  • Press F12. this will open Developer tools
  • Now tap on Console

For Safari:

  • Press Option + Command + C

Now we have opened the console and here comes the next step.

Downloading a view only PDF file

Copy the link below and paste it in the console. Make sure to clear the console before pasting the code. Scroll down to the bottom of the PDF file so that every page of it is copied.

// Loading the jsPDF library from a CDNconst script = document.createElement(‘script’);script.src = ‘enter link of the view only file’;document.head.appendChild(script);
// Waiting for the library to loadscript.onload = () => {  // Createing a new jsPDF instance  const pdf = new jsPDF();
  // Getting all images on the page  const images = document.getElementsByTagName(‘img’);
  // Loop through each image  for (let i = 0; i < images.length; i++) {    const image = images[i];
    // Checking if the image is a blob URL    if (image.src.startsWith(‘blob:’)) {      // Creating a canvas element with the same dimensions as the image      const canvas = document.createElement(‘canvas’);      canvas.width = image.naturalWidth;      canvas.height = image.naturalHeight;
      // Drawing the image onto the canvas      const context = canvas.getContext(‘2d’);      context.drawImage(image, 0, 0);
      // Converting the canvas to a data URL      const dataUrl = canvas.toDataURL(‘image/jpeg’);
      // Adding image to the PDF      pdf.addImage(dataUrl, ‘JPEG’, 0, 0);
      // Adding new page to the PDF      pdf.addPage();    }  }
  // Saving the PDF as a file named “downloadsample.pdf”  pdf.save(‘downloadsample.pdf’);};

This code will download the view only PDF file whether it is shared from Google Drive, OneDrive, Sharepoint or Dropbox. However make sure that your browser’s console supports running JS code. The code added above generates new instances of jspdf by loading the library. It creates canvas for all images and draws images to the element and adds new pages to the pdf. 

Downloading a view only PPT file

Now let’s we have a view only PPT file then we will paste the following code:

// Load the pptxgenjs library from a CDNconst script = document.createElement(‘script’);script.src = ‘link of the view only ppt’;document.head.appendChild(script);
// Wait for the library to loadscript.onload = () => {  // Create a new PowerPoint presentation  const pptx = new PptxGenJS();
  // Get all images on the page  const images = document.getElementsByTagName(‘img’);
  // Loop through each image  for (let i = 0; i < images.length; i++) {    const image = images[i];
    // Checking if the image is a blob URL    if (image.src.startsWith(‘blob:’)) {      // Add a new slide to the presentation      const slide = pptx.addSlide();
      // Add the image to the slide      slide.addImage({        data: image.src,        x: 0,        y: 0,        w: image.naturalWidth,        h: image.naturalHeight      });    }  }
  // Saving PowerPoint presentation as a file named “downloadsampl.pptx”  pptx.writeFile(‘downloadsample.pptx’);};

The above code will work in the same way as the previous code works. It will make screenshots of the all PPT pages and then combine it in a separate file and download it. 

Downloading view only Google docs or sheets

The method used for this will be different from above discussed methods because Google Docs or sheets are web based applications and that is the reason we can’t take screenshots of such a file as these types of files don’t exist as static pages. 

In such a case we will need an access token to authenticate the application. Once we have got the access token then we can use it in the code and it will download view only docs in form of word file and sheets in form of excel file.

// enter ACCESS_TOKEN with your actual access tokenconst accessToken = ‘Enter access token’;
// Replace YOUR_DOC_ID with the ID of the Google Doc you want to downloadconst docId = ‘_DOC_ID’;
// Create a new HTTP request to download the Google Doc as a Microsoft Word fileconst xhr = new XMLHttpRequest();xhr.open(‘GET’, `link of the view only doc file`, true);xhr.setRequestHeader(‘Authorization’, `Bearer ${accessToken}`);xhr.responseType = ‘blob’;
// When the request is complete, download the filexhr.onload = function() {  const blob = xhr.response;  const url = window.URL.createObjectURL(blob);  const a = document.createElement(‘a’);  a.href = url;  a.download = ‘download.docx’;  document.body.appendChild(a);  a.click();  a.remove();  window.URL.revokeObjectURL(url);};xhr.send();

For Google sheets

// Replace YOUR_ACCESS_TOKEN with your actual access tokenconst accessToken = ‘access token ‘;
// Replace YOUR_SHEET_ID with the ID of the Google Sheet you want to downloadconst sheetId = ‘sheet id’;
// Create a new HTTP request to download the Google Sheet as a Microsoft Excel fileconst xhr = new XMLHttpRequest();xhr.open(‘GET’, `link of the sheet`, true);xhr.setRequestHeader(‘Authorization’, `Bearer ${accessToken}`);xhr.responseType = ‘blob’;
// When the request is complete, download the filexhr.onload = function() {  const blob = xhr.response;  const url = window.URL.createObjectURL(blob);  const a = document.createElement(‘a’);  a.href = url;  a.download = ‘download.xlsx’;  document.body.appendChild(a);  a.click();  a.remove();  window.URL.revokeObjectURL(url);};xhr.send();

Downloading a view only video file

If you have a view only video file which is shared with you from Google drive then it is easy to download it:

  • For this you have to open the video on Chrome
  • Open Developers tools by pressing F12 from the keyboard
Developers tools
  • Play your video by selecting its quality in the settings
  • In the “Network” option tap on “Videoplayback” option
  • This will open the video in new tab
videoplayback option
  • By tapping on three dots and tapping on download you can download it.

But what if the video is shared from OneDrive or SharePoint. 

You can use an on screen video recorder in such a case or you can get the JS code from the highlighted link of the post in the description. 

On the other hand you can also use a browser extension or an on screen recorder application for this. In case of a simple image you can take screenshots of the images and then add all screenshots in a simple file.

Conclusion

As I have given the related JS codes which will be helpful for you. You can download view only PPT, view only docs and sheets along with a view only video using this method. I hope it will be informative for you.